public function render($request, Exception $e)
{
if ($e instanceof HttpResponseException) {
return $e->getResponse();
} elseif ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
} elseif ($e instanceof AuthorizationException) {
$e = new HttpException(403, $e->getMessage());
} elseif ($e instanceof ValidationException && $e->getResponse()) {
return $e->getResponse();
}
$fe = FlattenException::create($e);
$handler = new SymfonyExceptionHandler(env('APP_DEBUG', false));
$decorated = $this->decorate($handler->getContent($fe), $handler->getStylesheet($fe));
$response = new Response($decorated, $fe->getStatusCode(), $fe->getHeaders());
$response->exception = $e;
return $response;
}