David accepted God's punishment, but he begged God not to discipline him in anger. Jeremiah also asked God to correct him gently and not in anger (Jer 10:24). David recognized that if God treated him with justice alone and not with mercy, he would be wiped out by God's wrath. Often we want God to show mercy to us and justice to everyone else. God in his kindness forgives us instead of giving us what we deserve.
Psalms 6:1
This is the first of seven "penitential" psalms, in which the writer humbly realizes his predicament (usually the result of sin), expresses sorrow over it, and demonstrates a fresh commitment to remain close to God. We don't know the cause of David's pain, but whatever the cause, he sought God for the remedy.
Psalms 6:6
Pouring out his heart with tears, David was completely honest with God. We can be honest with God even when we are filled with anger or despair because God knows us thoroughly and wants the very best for us. Anger may result in rash outward acts or turning inward in depression. But because we trust in our all-powerful God, we don't have to be victims of circumstance or be weighed down by the guilt of sin. Be honest with God, and he will help you turn your attention from yourself to him and his mercy.