4

使用相关文档安装 Laravel 和 Bugsnag 后,我发现NotFoundHttpException错误没有报告给 Bugsnag(但是notifyError是的)。我的问题是如何设置它以便报告所有错误,而不是一遍又一遍地使用这些行:

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

或者

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

我正在考虑像这样使用Handlerin app/exceptions

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

但是如果 Laravel/Bugsnag 集成文档中没有提到它,这是一个好习惯吗?这个Laracast 视频没有描述对异常处理程序的任何更改,并且设置似乎按预期工作。

4

2 回答 2

3

在 App\Exceptions\Handler 中,从 $dontReport 中删除所有 Exception 类。我不确定您为什么要报告所有错误,但这应该为您完成。

于 2017-01-10T13:03:54.087 回答
0

\app\Exceptions\Handler.php

覆盖 internalDontReport属性。下面是继承自的默认值\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,
];
于 2018-12-25T04:02:18.397 回答