From Sahih Bukhari (Hadith 5640):
Narrated `Aisha:(the wife of the Prophet) Allah's Messenger (ﷺ) said, "No calamity befalls a Muslim but that Allah expiates some of his sins because of it, even though it were the prick he receives from a thorn
Reference: Bukhari 5640