/** * Create a Symfony response for the given exception. * * @param \Exception $e * * @return \Symfony\Component\HttpFoundation\Response * * @SuppressWarnings(PHPMD.ShortVariable) */ protected function convertExceptionToResponse(Exception $e) { if (config('app.debug')) { return $this->renderExceptionWithWhoops($e); } return parent::convertExceptionToResponse($e); }
/** * @param \Exception $e * @return \Symfony\Component\HttpFoundation\Response */ protected function convertExceptionToResponse(Exception $e) : Response { if (!request()->ajax() && !request()->wantsJson()) { return parent::convertExceptionToResponse($e); } return response()->json(["code" => 500, "message" => $e->getMessage()], 500); }
protected function convertExceptionToResponse(Exception $e) { if (config('app.debug')) { $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); return response()->make($whoops->handleException($e), method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500, method_exists($e, 'getHeaders') ? $e->getHeaders() : []); } return parent::convertExceptionToResponse($e); }
/** * Convert the given exception into a Response instance. * * @param \Exception $e * @return \Symfony\Component\HttpFoundation\Response */ protected function convertExceptionToResponse(Exception $e) { //make sure we don't have any previous output. //we want clean error pages so we don't confuse the user. if (!env('APP_DEBUG')) { ob_clean(); return response()->view('errors.500', [], 500); } return parent::convertExceptionToResponse($e); }
/** * Create a Symfony response for the given exception. * * @param \Exception $e * @return \Symfony\Component\HttpFoundation\Response */ protected function convertExceptionToResponse(Exception $e) { if (config('app.debug')) { $whoops = new Whoops(); $whoops->pushHandler(new PrettyPage()); $whoops->register(); return SymfonyResponse::create($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); } return parent::convertExceptionToResponse($e); }
/** * Create a Symfony response for the given exception. * * @param \Exception $exception * @return Response */ protected function convertExceptionToResponse(Exception $exception) { if (App::runningInConsole()) { // display exception response in console readable form $message = get_class($exception) . PHP_EOL; $message .= $exception->getMessage() . PHP_EOL . $exception->getTraceAsString(); $statusCode = FlattenException::create($exception)->getStatusCode(); return \Illuminate\Http\Response::create($message, $statusCode); } return parent::convertExceptionToResponse($exception); }
protected function _convertExceptionToResponse(\Exception $exc) { try { if ($exc instanceof HttpException && \Request::ajax()) { return $this->renderHttpException($exc); } else { if ($this->isDebug || $exc instanceof HttpException) { return (new ExceptionRenderer($this->isDebug))->createResponse($exc); } else { // try to render custom error page for HTTP status code = 500 // (by default: resources/errors/500.blade.php) return $this->renderHttpException(new HttpException(500, $exc->getMessage(), $exc)); } } } catch (\Exception $exc2) { return parent::convertExceptionToResponse($exc2); } }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $exception * @return \Illuminate\Http\Response */ public function render($request, Exception $exception) { if ($exception instanceof AuthenticationException) { if ($request->ajax() || $request->wantsJson()) { return response('Unauthorized.', 401); } else { return redirect()->guest(route('auth.login')); } } // Send the response in json for ajax requests. if ($request->ajax()) { $error = $exception->getMessage() . ' on ' . $exception->getLine() . ' of ' . $exception->getFile(); logger()->error($exception); return response()->json(['error' => $error], 500); } // If it is a redirect exception, handle the redirect. if ($exception instanceof RedirectionExceptionInterface) { return redirect($exception->getUrl())->with('error', $exception->getMessage()); } // Is in debug mode, show the full whoops page. if (config('app.debug')) { return parent::convertExceptionToResponse($exception); } // Try to send the error to a custom view page. $code = $exception->getCode(); if (view()->exists("errors.{$code}")) { return response()->view("errors.{$code}", [], $code); } // If its an HTTP exception it will have a status code. // Use that status code to render a custom view. if ($this->isHttpException($exception)) { $code = $exception->getStatusCode(); if (view()->exists("errors.{$code}")) { return response()->view("errors.{$code}", [], $code); } return $this->renderHttpException($exception); } // Render it with the default laravel settings. return parent::render($request, $exception); }