I heard the Messenger of Allah ﷺ say, "No one should issue two different rulings on the same matter, nor should anyone judge between two disputants while he is angry."
أخبرنا الحسين بن منصور بن جعفر قال حدثنا مبشر بن عبد الله قال حدثنا سفيان بن حسين عن جعفر بن إياس عن عبد الرحمن بن أبي بكرة وكان عاملا على سجستان قال كتب إلي
سمعت رسول الله ﷺ يقول لا يقضين أحد في قضاء بقضاءين ولا يقضي أحد بين خصمين وهو غضبان
No references are available.
Bukhari transmitted it, in the Book of Judgments, chapter, "Should the judge pass judgment or issue a ruling while angry?", no. 7158, and Muslim, in the Book of Judgments, chapter on the dislike of a judge passing judgment while angry, no. 1717, from the hadith of Abdul-Rahman bin Abu Bakra with the same wording. It is also found in Al-Kubra, no. 5983.