https://dev.to/clintwinter https://laravel.com/docs/9.x/helpers#method-rescue is an alternative to the traditional try/catch block syntax required when you want to manually handle a thrown exception. The result of the callback will be returned if no exception is thrown.

$country = 'USA'; try { $alpha2 = (new ISO3166)->alpha3($country)['alpha2']; } catch (\Exception $e) { $alpha2 = null; }

That's where rescue's second parameter comes in: $isFalse = rescue(function () { throw new Exception; }, false); Exit fullscreen mode

rescue(function () { throw new Exception; }, function ($e) { // do exception related stuff return false; }); // => false
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners