كتاب الأيمان
27  
The Book of Oaths
(3)
Chapter: It is recommended for the one who swears an oath then sees that something else is better than it; To do that which is better and offer expiation for his oath
(3)
باب نَدْبِ مَنْ حَلَفَ يَمِينًا فَرَأَى غَيْرَهَا خَيْرًا مِنْهَا أَنْ يَأْتِيَ الَّذِي هُوَ خَيْرٌ وَيُكَفِّرَ عَنْ يَمِينِهِ
Sahih Muslim 1649 g

Abu Musa al-Ash'ari reported:

We came to Allah's Messenger (ﷺ) requesting him to provide us with riding camels. He (the Holy Prophet) said: There is nothing with me with which I should equip you. By Allah, I would not provide you with (riding camels). Then Allah's Messenger (ﷺ) sent to us three camels with spotted bumps. We said: We came to Allah's Messenger (ﷺ) asking him to equip us with riding animals. He took an oath that he could not equip us. We came to him and informed him. He said: By Allah, I do not take an oath, but when I find the other thing better than that, I do that which is better.
وَحَدَّثَنَا إِسْحَاقُ بْنُ إِبْرَاهِيمَ، أَخْبَرَنَا جَرِيرٌ، عَنْ سُلَيْمَانَ التَّيْمِيِّ، عَنْ ضُرَيْبِ بْنِ، نُقَيْرٍ الْقَيْسِيِّ عَنْ زَهْدَمٍ، عَنْ أَبِي مُوسَى الأَشْعَرِيِّ، قَالَ أَتَيْنَا رَسُولَ اللَّهِ صلى الله عليه وسلم نَسْتَحْمِلُهُ فَقَالَ ‏"‏ مَا عِنْدِي مَا أَحْمِلُكُمْ وَاللَّهِ مَا أَحْمِلُكُمْ ‏"‏ ‏.‏ ثُمَّ بَعَثَ إِلَيْنَا رَسُولُ اللَّهِ صلى الله عليه وسلم بِثَلاَثَةِ ذَوْدٍ بُقْعِ الذُّرَى فَقُلْنَا إِنَّا أَتَيْنَا رَسُولَ اللَّهِ صلى الله عليه وسلم نَسْتَحْمِلُهُ فَحَلَفَ أَنْ لاَ يَحْمِلَنَا فَأَتَيْنَاهُ فَأَخْبَرْنَاهُ فَقَالَ ‏"‏ إِنِّي لاَ أَحْلِفُ عَلَى يَمِينٍ أَرَى غَيْرَهَا خَيْرًا مِنْهَا إِلاَّ أَتَيْتُ الَّذِي هُوَ خَيْرٌ ‏"‏ ‏.‏
Reference : Sahih Muslim 1649g
In-book reference : Book 27, Hadith 16
USC-MSA web (English) reference : Book 15, Hadith 4050
  (deprecated numbering scheme)