66 lines
1.7 KiB
PHP
66 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Exceptions;
|
|
|
|
use Illuminate\Session\TokenMismatchException;
|
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
|
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
|
|
|
class Handler extends ExceptionHandler
|
|
{
|
|
/**
|
|
* A list of the exception types that are not reported.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $dontReport = [
|
|
RedirectTo::class,
|
|
CommandNotFoundException::class
|
|
];
|
|
|
|
/**
|
|
* A list of the inputs that are never flashed for validation exceptions.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $dontFlash = [
|
|
'password',
|
|
'password_confirmation',
|
|
];
|
|
|
|
/**
|
|
* register function
|
|
*
|
|
* @return void
|
|
*/
|
|
public function register()
|
|
{
|
|
$this->reportable(function (\Throwable $e) {
|
|
if (app()->bound('sentry')) {
|
|
app('sentry')->captureException($e);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* render function
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Throwable $e
|
|
* @return void|\Symfony\Component\HttpFoundation\Response
|
|
* @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
|
|
*/
|
|
public function render($request, \Throwable $e)
|
|
{
|
|
// phpcs:enable
|
|
// Redirect to connection if user is in BO and session timeout.
|
|
if ($request->is('bo', 'bo/*') and \get_class($e) === TokenMismatchException::class) {
|
|
if (\in_array('GET', $request->route()->methods)) {
|
|
return \redirect()->route($request->route()->getName());
|
|
} else {
|
|
return \redirect()->route('bo.dashboard');
|
|
}
|
|
}
|
|
return parent::render($request, $e);
|
|
}
|
|
}
|