You can create a custom exception render in the AppExceptionsHandler
class (in the /app/Exceptions/Handler.php
file).
For example, to render a different view when for the TokenMismatchException
error, you can change the render
method to something like this:
/**
* Render an exception into an HTTP response.
*
* @param IlluminateHttpRequest $request
* @param Exception $e
* @return IlluminateHttpResponse
*/
public function render($request, Exception $e)
{
if ($e instanceof IlluminateSessionTokenMismatchException) {
return response()->view('errors.custom', [], 500);
}
return parent::render($request, $e);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…