2 Chronicles 35:21

But he sent ambassadors to him, saying, What have I to do with thee, thou king of Judah? I come not against thee this day, but against the house wherewith I have war: for God commanded me to make haste: forbear thee from meddling with God, who is with me, that he destroy thee not.

Necho told Josiah that he had no quarrel with Judah but was hastening against another house in a war God had commanded him to carry out, and warned him to stop meddling with God who was with him or be destroyed. That warning was God's word to Josiah even though it came through Necho rather than directly to Josiah himself. It showed that Josiah should have withdrawn from the battle because it did not concern him. Instead he ignored the warning out of pride and self-confidence and chose his own course. Because he ignored it he died in the battle and could not be shielded from the consequences of his choice.