King David committed adultery with Bathsheba and killed her husband to cover up his sin. Nathan the prophet came to him, to warn him of his sin, and to rebuke him:
"And Nathan said to David, Thou art the man. Thus saith the LORD God of Israel, I anointed thee king over Israel, and I delivered thee out of the hand of Saul; And I gave thee thy master's house, and thy master's wives into thy bosom, and gave thee the house of Israel and of Judah; and if that had been too little, I would moreover have given unto thee such and such things. Wherefore hast thou despised the commandment of the LORD, to do evil in his sight? thou hast killed Uriah the Hittite with the sword, and hast taken his wife to be thy wife, and hast slain him with the sword of the children of Ammon. Now therefore the sword shall never depart from thine house; because thou hast despised me, and hast taken the wife of Uriah the Hittite to be thy wife. Thus saith the LORD, Behold, I will raise up evil against thee out of thine own house, and I will take thy wives before thine eyes, and give them unto thy neighbor, and he shall lie with thy wives in the sight of this sun. For thou didst it secretly: but I will do this thing before all Israel, and before the sun. And David said unto Nathan, I have sinned against the LORD. And Nathan said unto David, The LORD also hath put away thy sin; thou shalt not die." (2 Sam. 12.7-13)
King David's response was of repentance to life, and Nathan continues to have a place of honor and counsel and continues to preach God's word to his king.
But note the difference in a similar incident, this time in 2 Chronicles 16.7-10a:
"And at that time Hanani the seer came to Asa king of Judah, and said unto him, Because thou hast relied on the king of Syria, and not relied on the LORD thy God, therefore is the host of the king of Syria escaped out of thine hand. Were not the Ethiopians and the Lubims a huge host, with very many chariots and horsemen? yet, because thou didst rely on the LORD, he delivered them into thine hand. For the eyes of the LORD run to and fro throughout the whole earth, to show himself strong in the behalf of them whose heart is perfect toward him. Herein thou hast done foolishly: therefore from henceforth thou shalt have wars. Then Asa was wroth with the seer, and put him in a prison house; for he was in a rage with him because of this thing."
Asa responds in fury to the seer's rebuke and places him in prison. There's no repentance.
Both Hanani and Nathan must have trembled at their task. It required them to go before the king of their land and tell him that he had sinned. King David could have responded as King Asa did. But neither Nathan nor Hanani knew the outcome of their visit, but they spoke God's word as He had commanded them.
It's not easy for someone to tell us we've done wrong. We often lash out at those who do. But may God grant us faithful Hananis and Nathans. We need such men to tell us when we've done wrong. It's especially important for those in powerful positions to have such faithful men. But all of us need them. And may God grant them to us.