Anas (May Allah be pleased with him) reported:
The Prophet (ﷺ) passed by a woman who was crying over a grave and said, "Fear Allah and be patient." She said, "Away from me! My calamity has not befallen you and you are not aware of it." The woman was later told that it was the Prophet (ﷺ) (who had advised her). She came to his door where she found no doorkeeper. She said, "(I am sorry) I did not know you." Messenger of Allah (ﷺ) said, "Patience is (becoming) only at the first (stroke) of grief".[Al-Bukhari and Muslim].Another narration in Muslim says: The woman was crying over her son.
Arabic/English book reference: Book 1, Hadith 31