4

Having installed Laravel and Bugsnag using the relevant documentation, I found that an NotFoundHttpException error for instance is not reported to Bugsnag (but notifyError yes). My question is how to set it so that all errors are reported, without using these lines over and over:

Bugsnag::notifyError('ErrorType', 'Something bad happened');

or

try {
    // Some potentially crashy code
} catch (Exception $ex) {
    Bugsnag::notifyException($ex);
}

I'm thinking of using the Handler in app/exceptions like so:

public function report(Exception $e)
{
    Bugsnag::notifyException($e);
    parent::report($e);
}

But if it's not mentioned in the Laravel/Bugsnag integration docs, is it a good practice? This Laracast video doesn't describe any changes to the exceptions handler and the setup seems to work as intended.

greener
  • 4,989
  • 13
  • 52
  • 93

2 Answers2

3

In App\Exceptions\Handler, remove all Exception classes from $dontReport. I'm not sure why you'd want to report all errors, but this should do it for you.

Jon Donnell
  • 111
  • 1
  • 7
0

In

\app\Exceptions\Handler.php

overwrite internalDontReport property. Below is a default that comes inherited from \vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php

protected $internalDontReport = [
    AuthenticationException::class,
    AuthorizationException::class,
    HttpException::class,
    HttpResponseException::class,
    ModelNotFoundException::class,
    TokenMismatchException::class,
    ValidationException::class,
];
Yevgeniy Afanasyev
  • 37,872
  • 26
  • 173
  • 191