/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { switch (get_class($e)) { case "Swift_TransportException": case "PDOException": $errorView = "errors.500_config"; break; case "ErrorException": $errorView = "errors.500"; break; case "Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException": return abort(400); default: $errorView = false; break; } if ($errorView) { // This makes use of a Symfony error handler to make pretty traces. $SymfonyDisplayer = new SymfonyDisplayer(config('app.debug')); $FlattenException = FlattenException::create($e); $SymfonyCss = $SymfonyDisplayer->getStylesheet($FlattenException); $SymfonyHtml = $SymfonyDisplayer->getContent($FlattenException); $response = response()->view($errorView, ['exception' => $e, 'error_class' => get_class($e), 'error_css' => $SymfonyCss, 'error_html' => $SymfonyHtml], 500); return $this->toIlluminateResponse($response, $e); } else { return parent::render($request, $e); } }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Symfony\Component\HttpFoundation\Response */ public function render($request, Exception $e) { $e = FlattenException::create($e); $handler = new SymfonyExceptionHandler(env('APP_DEBUG', false)); $decorated = $this->decorate($handler->getContent($e), $handler->getStylesheet($e)); return Response::create($decorated, $e->getStatusCode(), $e->getHeaders()); }
/** * Convert an exception to a response * * @param \Exception $exception * @return \Symfony\Component\HttpFoundation\Response */ public function handleException($exception) { if (!$exception instanceof FlattenException) { $exception = FlattenException::create($exception); } $handler = new BaseExceptionHandler($this->debug); $decorated = $this->decorate($handler->getContent($exception), $handler->getStylesheet($exception)); return new Response($decorated, $exception->getStatusCode(), $exception->getHeaders()); }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { if ($e instanceof ErrorException) { // This makes use of a Symfony error handler to make pretty traces. $SymfonyDisplayer = new SymfonyDisplayer(config('app.debug')); $FlattenException = FlattenException::create($e); $SymfonyCss = $SymfonyDisplayer->getStylesheet($FlattenException); $SymfonyHtml = $SymfonyDisplayer->getContent($FlattenException); return response()->view('errors.500', ['error' => $e, 'error_css' => $SymfonyCss, 'error_html' => $SymfonyHtml], 500); } else { return parent::render($request, $e); } }
/** * Renders the exception panel stylesheet for the given token. * * @param string $token The profiler token * * @return Response A Response instance * * @throws NotFoundHttpException */ public function cssAction($token) { if (null === $this->profiler) { throw new NotFoundHttpException('The profiler must be enabled.'); } $this->profiler->disable(); $exception = $this->profiler->loadProfile($token)->getCollector('exception')->getException(); $template = $this->getTemplate(); if (!$this->templateExists($template)) { $handler = new ExceptionHandler($this->debug, $this->twig->getCharset()); return new Response($handler->getStylesheet($exception), 200, array('Content-Type' => 'text/css')); } return new Response($this->twig->render('@WebProfiler/Collector/exception.css.twig'), 200, array('Content-Type' => 'text/css')); }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ 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; }
/** * Create a Symfony response for the given exception. * * @param \Exception $e * @return \Symfony\Component\HttpFoundation\Response */ protected function convertExceptionToResponse(Exception $e) { $e = FlattenException::create($e); $handler = new SymfonyExceptionHandler(config('app.debug')); $decorated = $this->decorate($handler->getContent($e), $handler->getStylesheet($e)); return SymfonyResponse::create($decorated, $e->getStatusCode(), $e->getHeaders()); }
/** * Render an exception into an HTTP response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { $errorView = false; $errorEmail = false; switch (get_class($e)) { case "App\\Exceptions\\TorClearnet": $errorView = "errors.403_tor_clearnet"; break; case "Swift_TransportException": case "PDOException": $errorView = "errors.500_config"; $errorEmail = true; break; case "ErrorException": case "Symfony\\Component\\Debug\\Exception\\FatalThrowableError": $errorView = "errors.500"; $errorEmail = true; break; case "Symfony\\Component\\HttpKernel\\Exception\\MethodNotAllowedHttpException": return abort(400); case "Predis\\Connection\\ConnectionException": $errorView = "errors.500_predis"; $errorEmail = true; break; default: $errorView = false; break; } if (env('APP_DEBUG', false)) { $errorView = false; } $errorEmail = $errorEmail && env('MAIL_ADDR_ADMIN', false) && env('MAIL_ADMIN_SERVER_ERRORS', false); if ($errorEmail) { // This makes use of a Symfony error handler to make pretty traces. $SymfonyDisplayer = new SymfonyDisplayer(true); $FlattenException = isset($FlattenException) ? $FlattenException : FlattenException::create($e); $SymfonyCss = $SymfonyDisplayer->getStylesheet($FlattenException); $SymfonyHtml = $SymfonyDisplayer->getContent($FlattenException); $data = ['exception' => $e, 'error_class' => get_class($e), 'error_css' => $SymfonyCss, 'error_html' => $SymfonyHtml]; Mail::send('emails.error', $data, function ($message) { $to = env('SITE_NAME', 'Infinity Next') . " Webaster"; $subject = env('SITE_NAME', 'Infinity Next') . " Error"; $subject .= " " . Request::url() ?: ""; $message->to(env('MAIL_ADDR_ADMIN', false), $to); $message->subject($subject); }); } if ($errorView) { // Duplicating logic in $errorEmail because output is completely // diffrent without app.debug enabled. I always want a stack trace // in my emails! $SymfonyDisplayer = new SymfonyDisplayer(config('app.debug')); $FlattenException = isset($FlattenException) ? $FlattenException : FlattenException::create($e); $SymfonyCss = $SymfonyDisplayer->getStylesheet($FlattenException); $SymfonyHtml = $SymfonyDisplayer->getContent($FlattenException); $response = response()->view($errorView, ['exception' => $e, 'error_class' => get_class($e), 'error_css' => $SymfonyCss, 'error_html' => $SymfonyHtml], 500); return $this->toIlluminateResponse($response, $e); } return parent::render($request, $e); }
protected function originalConvertExceptionToResponseWithDebugEnabled(Exception $exc) { // needed for emails and file logs, otherwise it will be useless $e = FlattenException::create($exc); $handler = new SymfonyExceptionHandler(true); $decorated = $this->decorate($handler->getContent($e), $handler->getStylesheet($e)); return SymfonyResponse::create($decorated, $e->getStatusCode(), $e->getHeaders()); }