diff --git a/config/flare.php b/config/flare.php index 111dd9d..c811478 100644 --- a/config/flare.php +++ b/config/flare.php @@ -6,7 +6,7 @@ use Spatie\FlareClient\FlareMiddleware\CensorRequestHeaders; use Spatie\LaravelIgnition\FlareMiddleware\AddDumps; use Spatie\LaravelIgnition\FlareMiddleware\AddEnvironmentInformation; -use Spatie\LaravelIgnition\FlareMiddleware\AddExceptionHandled; +use Spatie\LaravelIgnition\FlareMiddleware\AddExceptionHandledStatus; use Spatie\LaravelIgnition\FlareMiddleware\AddExceptionInformation; use Spatie\LaravelIgnition\FlareMiddleware\AddJobs; use Spatie\LaravelIgnition\FlareMiddleware\AddLogs; @@ -56,7 +56,7 @@ 'max_chained_job_reporting_depth' => 5, ], AddContext::class, - AddExceptionHandled::class, + AddExceptionHandledStatus::class, CensorRequestBodyFields::class => [ 'censor_fields' => [ 'password', diff --git a/src/FlareMiddleware/AddExceptionHandled.php b/src/FlareMiddleware/AddExceptionHandled.php deleted file mode 100644 index 18ce2b7..0000000 --- a/src/FlareMiddleware/AddExceptionHandled.php +++ /dev/null @@ -1,48 +0,0 @@ -limit(40)->frames(); - $frameCount = count($frames); - - foreach ($frames as $i => $frame) { - // Check first frame, probably Illuminate\Foundation\Exceptions\Handler::report() - // Next frame should be: Illuminate/Foundation/helpers.php::report() - - if ($frame->method !== 'report') { - continue; - } - - if ($frame->class === null) { - continue; - } - - if ($i === $frameCount - 1) { - continue; - } - - if ($frames[$i + 1]->class !== null) { - continue; - } - - if ($frames[$i + 1]->method !== 'report') { - continue; - } - - $report->handled(); - - break; - } - - return $next($report); - } -} diff --git a/src/FlareMiddleware/AddExceptionHandledStatus.php b/src/FlareMiddleware/AddExceptionHandledStatus.php new file mode 100644 index 0000000..9e9f20b --- /dev/null +++ b/src/FlareMiddleware/AddExceptionHandledStatus.php @@ -0,0 +1,53 @@ +limit(40)->frames(); + $frameCount = count($frames); + + try { + foreach ($frames as $i => $frame) { + // Check first frame, probably Illuminate\Foundation\Exceptions\Handler::report() + // Next frame should be: Illuminate/Foundation/helpers.php::report() + + if ($frame->method !== 'report') { + continue; + } + + if ($frame->class === null) { + continue; + } + + if ($i === $frameCount - 1) { + continue; + } + + if ($frames[$i + 1]->class !== null) { + continue; + } + + if ($frames[$i + 1]->method !== 'report') { + continue; + } + + $report->handled(); + + break; + } + } catch (Throwable) { + // Do nothing + } + + return $next($report); + } +}