The Messenger of Allah ﷺ said, "Whoever swears an oath and adds an exception, may either go back on it or leave it, without breaking the oath."
حدثنا محمد بن عيسى ومسدد وهذا حديثه قالا حدثنا عبد الوارث عن أيوب عن نافع
قال رسول الله ﷺ من حلف فاستثنى فإن شاء رجع وإن شاء ترك غير حنث
Graded, its isnad is sahih. Tirmidhi collected it, in the Book of Vows and Oaths, chapter on what has been said regarding making an exception in an oath, no. 1531, Nasai, no. 3824, and Ibn Majah, no. 2105, from the hadith of Abdul-Warith, through this route, and Tirmidhi said, hasan.