The Messenger of Allah ﷺ taught me that whenever distress befalls me, I should say, "There is no god but Allah, the Forbearing, the Generous. Glory be to Allah, and blessed is Allah, Lord of the Mighty Throne. All praise belongs to Allah, Lord of the worlds."
علمني رسول الله ﷺ إذا نزل بي كرب أن أقول: لا إله إلا الله الحليم الكريم، سبحان الله وتبارك الله رب العرش العظيم، والحمد لله رب العالمين.
Ahmad narrated it (721, 726), Nasai in Amal al-Yawm wal-Layla (630), and Ibn Sunni (342), and Ibn Hibban graded it sahih (865), as did Hakim (1/508), all of them through the route of Muhammad bin Kaab Qurazi, from Abdullah bin Shaddad bin Had, from Abdullah bin Jafar (who is the son of Abu Talib), from Ali bin Abu Talib, who related it. Its chain of transmission is sahih, and Hakim said, "This is a sahih hadith according to the criteria of Muslim." Ibn Hajar also graded it sahih, as mentioned in Futuhat Rabbaniya by Ibn Allan (7/4). Nasai gave extensive mention of its various routes and wordings.