ldc-boutique-cnc/app/Exceptions/Handler.php
Jérémy Munsch 93c94dca8b
Add sentry
2023-02-08 10:02:03 +01:00

61 lines
1.3 KiB
PHP

<?php
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [];
/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];
/**
* Report or log an exception.
*
* @param \Throwable $e
* @return void
*
* @phpcs:ignore Squiz.Commenting.FunctionComment.EmptyThrows
* @throws \Exception
*/
public function report(\Throwable $e)
{
// phpcs:enable
if (get_class($e) == RedirectTo::class) {
abort(redirect($e->url));
}
if ($this->shouldntReport($e)) {
return;
}
parent::report($e);
}
/**
* Register the exception handling callbacks for the application.
*
* @return void
*/
public function register()
{
$this->reportable(function (\Throwable $e) {
if (app()->bound('sentry')) {
app('sentry')->captureException($e);
}
});
}
}