Skip to content

Ability to Always Report exceptions

Compare
Choose a tag to compare
@deleugpn deleugpn released this 13 Jan 11:47
80ccca4

We don't want Laravel to hide exceptions declared in the internalDontReport because SQS is a background job and if these exceptions are not reported, they will be invisible to the developer. We tried the approach of wrapping them up on a new Exception but this has the side effect of hiding away the backtrace even when we send in the previousException parameter.

With this version, we allow the Laravel project to modify it's Handler.php by implementing the AlwaysReportExceptionHandler and provide the following method:

public function alwaysReport(Throwable $e): void
    {
        $internalDontReport = $this->internalDontReport;

        $dontReport = $this->dontReport;

        $this->internalDontReport = [];

        $this->dontReport = [];

        parent::report($e);

        $this->internalDontReport = $internalDontReport;

        $this->dontReport = $dontReport;
    }