fix(handler): improve exception reporting to Sentry by honoring application's report policy
This commit is contained in:
parent
1c0eefa160
commit
a0d4699cdf
|
|
@ -648,7 +648,15 @@ class Handler implements MessageComponentInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (app()->bound('sentry')) {
|
// Honour the application's report policy (dontReport + the
|
||||||
|
// framework's internal don't-report list) so expected
|
||||||
|
// exceptions thrown by controllers — ValidationException,
|
||||||
|
// AuthenticationException, etc. — don't flood Sentry from the
|
||||||
|
// WS bridge the way the HTTP layer already suppresses them.
|
||||||
|
$handler = app(\Illuminate\Contracts\Debug\ExceptionHandler::class);
|
||||||
|
$shouldReport = ! method_exists($handler, 'shouldReport') || $handler->shouldReport($e);
|
||||||
|
|
||||||
|
if ($shouldReport && app()->bound('sentry')) {
|
||||||
app('sentry')->captureException($e);
|
app('sentry')->captureException($e);
|
||||||
}
|
}
|
||||||
} catch (\Throwable $sentryError) {
|
} catch (\Throwable $sentryError) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue