It is narrated from Safwan bin Abdullah bin Safwan that someone said to Safwan bin Umayyah (may Allah be pleased with him): "Whoever has not migrated is ruined." So Safwan (may Allah be pleased with him) came to Madinah and placed his cloak under his head and slept in the mosque. A thief came and took the cloak from under his head. Safwan (may Allah be pleased with him) caught the thief and brought him to the Prophet ﷺ. The Messenger of Allah ﷺ ordered and his hand was cut off. Then Safwan (may Allah be pleased with him), feeling pity, said: "That was not my intention; I give the cloak to him as charity." So the Prophet ﷺ said: "Why did you not do this before bringing him to me?"
Hadith Referenceمسند الإمام الشافعي / كتاب الحدود / 1590
Hadith Takhrijاخرجه ابو داود، الحدود، باب فيمن سرق من حرز (4394) والنسائي ، قطع السارق، باب ما يكون حرزا ومالا يكون (4887) - وصححه ابن الجارود (828) والحاكم (4/ 380)۔