2021-05-25 12:15:02 +00:00
|
|
|
<?php
|
2015-07-19 06:49:24 +00:00
|
|
|
|
2021-05-25 12:15:02 +00:00
|
|
|
namespace App\Exceptions;
|
|
|
|
|
|
|
|
// use Exception;
|
2015-07-19 06:49:24 +00:00
|
|
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
2021-05-25 12:15:02 +00:00
|
|
|
use Throwable;
|
2015-07-19 06:49:24 +00:00
|
|
|
|
2019-11-21 17:43:56 +00:00
|
|
|
class Handler extends ExceptionHandler
|
|
|
|
{
|
2015-07-19 06:49:24 +00:00
|
|
|
|
2019-11-21 17:43:56 +00:00
|
|
|
/**
|
|
|
|
* A list of the exception types that should not be reported.
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $dontReport = [
|
2021-05-25 12:15:02 +00:00
|
|
|
'password',
|
|
|
|
'password_confirmation',
|
2019-11-21 17:43:56 +00:00
|
|
|
];
|
2015-07-19 06:49:24 +00:00
|
|
|
|
2019-11-21 17:43:56 +00:00
|
|
|
/**
|
|
|
|
* Report or log an exception.
|
|
|
|
*
|
|
|
|
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
|
|
|
*
|
2021-05-25 12:15:02 +00:00
|
|
|
* @param \Throable $exception
|
2019-11-21 17:43:56 +00:00
|
|
|
* @return void
|
|
|
|
*/
|
2021-05-25 12:15:02 +00:00
|
|
|
public function report(Throwable $exception)
|
2019-11-21 17:43:56 +00:00
|
|
|
{
|
2021-05-25 12:15:02 +00:00
|
|
|
return parent::report($exception);
|
2019-11-21 17:43:56 +00:00
|
|
|
}
|
2015-07-19 06:49:24 +00:00
|
|
|
|
2021-05-25 12:15:02 +00:00
|
|
|
/**
|
2019-11-21 17:43:56 +00:00
|
|
|
* Render an exception into an HTTP response.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
2021-05-25 12:15:02 +00:00
|
|
|
* @param \Throwable $exception
|
|
|
|
* @return \Symfony\Component\HttpFoundation\Response
|
|
|
|
*
|
|
|
|
* @throws \Throwable
|
2019-11-21 17:43:56 +00:00
|
|
|
*/
|
2021-05-25 12:15:02 +00:00
|
|
|
public function render($request, Throwable $ex)
|
2019-11-21 17:43:56 +00:00
|
|
|
{
|
|
|
|
if ($ex instanceof \Illuminate\Auth\Access\AuthorizationException) {
|
|
|
|
// return $this->errorResponse($exception->getMessage(), 403);
|
|
|
|
return redirect('/login', 302)
|
|
|
|
->with('error', 'The form has expired due to inactivity. Please try again');
|
|
|
|
// redirect()->guest($ex->redirectTo() ?? route('login'));
|
|
|
|
}
|
|
|
|
// if ($ex instanceof AuthorizationException) {
|
|
|
|
// // return $this->errorResponse($exception->getMessage(), 403);
|
|
|
|
// return redirect('/login', 302)
|
|
|
|
// // ->back()
|
|
|
|
// // ->withInput($request->except(['password', 'password_confirmation']))
|
|
|
|
// ->with('error', 'The form has expired due to inactivity. Please try again');
|
|
|
|
// }
|
2015-07-19 06:49:24 +00:00
|
|
|
|
2019-11-21 17:43:56 +00:00
|
|
|
// if ($ex instanceof \Illuminate\Session\TokenMismatchException) {
|
|
|
|
// // return redirect('/login', 302)
|
|
|
|
// // // ->back()
|
|
|
|
// // // ->withInput($request->except(['password', 'password_confirmation']))
|
|
|
|
// // ->with('error', 'The form has expired due to inactivity. Please try again');
|
|
|
|
// return response()->json(array(
|
|
|
|
// 'success' => true,
|
|
|
|
// //'redirect' => route('settings.document.edit', ['id' => $dataset->server_state]),
|
|
|
|
// 'redirect' => route('login')
|
|
|
|
// ));
|
|
|
|
// }
|
|
|
|
return parent::render($request, $ex);
|
|
|
|
}
|
2015-07-19 06:49:24 +00:00
|
|
|
}
|