Sahih Muslim Book 45, Hadith 64
No trouble comes to a believer even if it is the pricking of a thorn that it becomes (the means) whereby his sins are effaced or his sins are obliterated. Yazid says: He does not know which word 'Urwa said (whether he said Qussa or Kuffira).
Allah's Messenger (ﷺ) said: There is no trouble that comes to a believer except that it obliterates from his sins, even if it is the pricking of a thorn
I heard Allah's Messenger (ﷺ) as saying: There is nothing (in the form of trouble) that comes to a believer even if it is the pricking of a thorn that there is decreed for him by Allah good or his sins are obliterated.