ldc-boutique-cnc/app/Exceptions/Handler.php

62 lines
1.3 KiB
PHP
Raw Normal View History

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