2 Kings 22:18

But to the king of Judah which sent you to enquire of the LORD, thus shall ye say to him, Thus saith the LORD God of Israel, As touching the words which thou hast heard;

The Lord's personal message to Josiah came through Huldah in answer to the inquiry the king had sent to the Lord. The words he had heard were God's warning of judgment on Judah, that its place and its inhabitants would become a desolation and a curse. His heart was tender at that warning, and he humbled himself before God, tore his clothes, wept before Him, and promptly sought forgiveness and mercy.

Because he humbled his heart, God acknowledged him, heard him, and showed him personal mercy. That mercy meant, as the following words explain, that he would die in peace without seeing the coming disaster. Jerusalem's ruin and the nation's punishment could not be averted because the people's provocation had become too great, so Josiah had to leave future events with God.