Sayyiduna Abd al-Rahman bin Samurah (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) said to me: "O Abu Abd al-Rahman! Do not ask for leadership. If it is given to you because you asked for it, you will be left to it; and if it is given to you without your asking, you will be helped in it. When you swear an oath to do something and another thing is better than it, then expiate your oath and do what is better."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / 20246