When forbidding sins destructive of the order in the irascible emotions, he gives his warning when he says Be angry, and sin not. This is susceptible of two interpretations; for there are two types of anger, a good one and an evil one. Anger is evil when, contrary to justice, it strives inordinately for revenge. It is good when it seeks a just vindication, namely, when the person is vexed at the time, with whom, and to the degree that, he should be. The above warning is applicable to both.
If it concerns evil anger, the sense is that he does not command it but permits it. As though he said: S...hould it happen that anger wells up within you—which is human enough—do not sin. You must not be led on to perform what the inordinate passion craves through consenting to it. "Let no temptation take hold on you, but such as is human" (1 Cor. 10:13). For, without doubt, whoever is angered against his brother in any other way "shall be in danger of the judgment" (Mt. 5:22). Joseph counselled his brothers against such anger: "Be not angry in the way" (Gen. 45:24).
If it is interpreted concerning righteous anger it is not simply permitted, like the first, but imperative. Be angry against your sins, for man desires a twofold vindication. One regarding himself when he sins, so that penance becomes a certain type of vindication which man inflicts and receives in himself. Such a wrath is good, and with respect to it the imperative is used: be angry against your sins, and sin not any more, nor commit those types of sin with which you must again be exasperated.
Now, some are doubtless of the opinion that a man can be mad at himself for his own sins safely, but that this does not hold true concerning his neighbors and their sins. This is false; a man can be mad at himself for his own sins, and at his fellow man because of his sins. Therefore, zealously be angry at other people's offenses. "Phinees hath turned away my wrath from the children of Israel because he was moved with my zeal against them" (Num. 25:11). And Elias said: "With zeal have I been zealous for the Lord God of Hosts: for the children of Israel have forsaken thy covenant" (3 Kg. 19:10). By following the dictates of reason, rather than acting before reason has had time to reflect, you sin not. "Let every man be swift to hear, but slow to speak, and slow to anger" (Jas. 1:19).
In "Let not the sun go down upon your anger" he explains what he had said, and the explanation can be interpreted according to the three above expositions. If it concerns evil anger, then he would be saying: Do not nurture seeds of wrath, cast them off before sunset; for although the first impulses of temper are excusable, due to human frailty, it is illicit to dwell on them.
In reference to good anger, as it is directed against one's personal sins, the sun is Christ. "Unto you that fear my name the sun of justice shall arise" (Mal. 4:2). Let not it go down upon your anger, that is, on your sins, on account of which you must be angered again and punish yourselves. When the sins of others are in question the sun refers to reason. "Remember thy Creator in the days of thy youth, before the time of affliction come, and the years draw nigh of which thou shalt say: They please me not; before the sun... is darkened" (Eccl. 12:1). The sun should not set on your anger, that is, the dictates of reason must not be clouded over. "Anger indeed killeth the foolish" (Job 5:2).
Source: Commentary on Ephesians