Anger is an appropriate response of God to our sin for two main reasons. Firstly it is an affront to God: we have not trusted, listened and obeyed him. Secondly, our wrongdoing always harms ourselves and those around us. A loving God sees the consequences of our sin more than we do. It's like a parent who gets angry that one son opens the gate to a main road and the younger brother wanders out, unaware of the danger of passing cars.
Anger in people can be an appropriate response if we, too, see the repugnance of sin and the danger of its consequences. Anger can motivate us to take action, to speak up, to intervene where someone is being treated wrongly.
The difference between capricious and effective anger is that one flares up in the heat of the moment and may be tainted by our "holier than thou" attitudes, selfish indignation that we are being insulted, and so on. The other is tempered by self-control ( a fruit of the Spirit), prayer, wisdom and good timing.
Sometimes we need to act quickly, as when someone's life is in danger, but mostly there is time to take our anger to God and pray about a right response. If I myself am the victim of an injustice or hurt, I need to take that to the cross first, along with any elements of judgement, hurt pride, desire for revenge, etc. Once I am at peace with God and the person who has hurt me, I am more in a position to see how to act or what to say to rectify any injustice, misunderstanding or harm. We can also become very angry at the injustice or harm meted out to someone else. This, too, needs to be purified in prayer so that any wrong attitudes are put right before we take up our banners and start fighting a cause.