// app/Exceptions/Handler.php
public function report(Exception $exception)
{
if (app()->bound('sentry') && $this->shouldReport($exception)){
app('sentry')->captureException($exception);
}
parent::report($exception);
}
We added the common way Sentry to our Laravel project, so frameworkj is handling the not-catched exceptions sending the exception to sentry.
The problem was that in a few cases, we need both to handled the exception in the code with a try / catch AND to log it to sentry to evidence a rare situation we're still investigating. Our code is able to 'survide' to the exception, and it MUST survive, so we need the catch; but catched exception are not logged to sentry, and we need to log this particular exception to sentry to allow better investigation about the problem.