Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:68:49

If not that a favor from his Lord overtook him, he would have been thrown onto the naked shore while he was censured.  

Had it not been for a grace, a mercy, from his Lord that reached him, he would have surely been cast, out of the belly of the whale, onto a wilderness, a desolate land, while he was blameworthy — but he was shown mercy and was therefore cast out blameless.
القرآن:٦٨:٤٩

لَوْلَا أَنْ تَدَارَكَهُ نِعْمَةٌ مِنْ رَبِّهِ لَنُبِذَ بِالْعَرَاءِ وَهُوَ مَذْمُومٌ  

{لولا أن تداركه} أدركه {نعمة} رحمة {من ربه لنبذ} من بطن الحوت {بالعراء} بالأرض الفضاء {وهو مذموم} لكنه رحم فنبذ غير مذموم.