Anger, of itself, is not a sin (Eph. 4.26).
Nevertheless, there are certain types of anger that cross the line. A comparison of Matthew 2.16 with 3.7 will help to identify that line.
King Herod desired to destroy the young messiah, using the wise men to locate him (Mt. 2.8). When God thwarted those plans, Herod became “exceedingly enraged” (2.16), leading him to slaughter the innocent boys of Bethlehem.
Matthew employs the term, thumoo, to describe his anger. It suggests an impulsive “outburst” (Gal. 5.20), driven by passion, hot at its core (think, thermal). It burns uncontrollably, quickly.
Thumos is usually a negative trait in the Bible, particularly with reference to human emotions (cf. Lk. 4.28; Acts 19.28; Gal. 5.20, etc.), although it is sometimes used with reference to divine wrath for sin, stressing, not the inward passions of God, but the external fierceness of his judgment against the impenitent (cf. Rm. 2.8; Rev. 16.19; 19.15).
By contrast, a few verses later, John asks the Pharisees and Sadducees: “Who forewarned you to flee from the coming wrath?” (3.7). Here, the word is: orge. It evinces a more settled, deliberate anger, often rooted in principle rather than impetuous agitation.
Observe that the wrath of God is “coming” — implying that it is being reserved for the moment; it is planned, rather than spontaneous.
Among humans, anger (orge) is not always justifiable (cf. Col. 3.8; James 1.19-20). But when our anger is settled, rooted in righteous principle, and under control, it may be justified temporarily (cf. Eph. 4.26b; Mk. 3.5).
Eventually, however, it must be released into the care and custody of a just and providential God (cf. Rom. 12.19). We must never hold on to anger, however justified it might be. Take it to the Lord. He will take care of the matter ultimately (cf. Rm. 1.18; Col. 3.6; 1 Pet. 2.23).