The Messenger of Allah ﷺ said, "A judge must not pass judgment between two parties while he is angry."In Hisham's version of the report, the wording is, "It is not proper for a judge to pass judgment between two parties while he is angry."
حدثنا هشام بن عمار ومحمد بن عبد الله بن يزيد وأحمد بن ثابت الجحدري قالوا حدثنا سفيان بن عيينة عن عبد الملك بن عمير أنه
أن رسول الله ﷺ قال لا يقضي القاضي بين اثنين وهو غضبان قال هشام في حديثه لا ينبغي للحاكم أن يقضي بين اثنين وهو غضبان
Bukhari narrated it in the Book of Judgments, chapter "Should a judge issue a ruling or a legal opinion while angry?", no. 7158, and Muslim narrated it in the Book of Judgments, chapter on the dislike of a judge issuing a ruling while angry, no. 1717, from the hadith of Abdul-Malik, with the same wording.