/** * 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 ($this->isHttpException($e)) { return $this->renderHttpException($e); } elseif ($e instanceof OAuthException) { return Response::json(['error' => $e->errorType, 'message' => $e->getMessage()], $e->httpStatusCode); } if (config('app.debug')) { $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->setEditor('sublime'); $whoops = new \Whoops\Run(); $whoops->pushHandler($handler); return response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); } return parent::render($request, $e); }
/** * HTTPレスポンスに対応する例外をレンダー * * @param \Illuminate\Http\Request $request * @param \Exception $e * * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { if (config('app.debug')) { $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Hander\PrettyPageHander()); return new \Illuminate\Http\Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); } // CSRFトークンが存在しない、トークン不一致時に投げられる。 // TokenMismatchException例外を403で処理。 // もちろん適切であれば、HTTPステータスは自由に設定できる。 if ($e instanceof TokenMismatchException) { // abortヘルパーによりSymfony\Component\HttpFoundation\Exception\HttpException例外が // 投げられ、再度このrenderメソッドで処理される。この例外の // ステータスコードに一致するビューがapp/resources/views/errorsに // 存在していれば、そのビューが表示される。今回は403.blade.phpファイルが // 存在しているため、このファイルの内容がエラーページとして表示される。 abort(403); } // このrenderメソッドに最初から含まれている処理。 // EloquentのfindOrFailソッドなどが投げるModelNotFoundException例外を // 404エラーにしている。 if ($e instanceof ModelNotFoundException) { // 404エラー例外はabort(404)を使わず、次のように発生可能。 $e = new NotFoundHttpException($e->getMessage(), $e); } return parent::render($request, $e); }
/** * Render an exception into a response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Symfony\Component\HttpFoundation\Response */ public function render($request, Exception $e) { $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); return new Response($whoops->handleException($e)); //, $e->getStatusCode(), $e->getHeaders() }
public function renderExceptionWithWhoops($request, $e) { $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler()); return new Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); //return Response::view('errors.503'); }
protected function renderExceptionWithWhoops(Exception $e) : Response { $this->unsetSensitiveData(); $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); return new \Illuminate\Http\Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); }
/** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $e) { $whoops = new \Whoops\Run(); $handler = $_SERVER['REQUEST_METHOD'] == "GET" ? new \Whoops\Handler\PrettyPageHandler() : new \Whoops\Handler\PlainTextHandler(); $whoops->pushHandler($handler); return new \Illuminate\Http\Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); }
/** * Render an ajax exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderAjaxExceptionWithWhoops($e) { $whoops = new \Whoops\Run(); $jsonHandler = new \Whoops\Handler\JsonResponseHandler(); $jsonHandler->addTraceToOutput(true); $whoops->pushHandler($jsonHandler); return new \Illuminate\Http\Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); }
/** * Render an exception into an HTTP response using Whoops. * * @return \Illuminate\Http\Response */ protected function whoops(Exception $e) { $whoops = new \Whoops\Run(); $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->setEditor('sublime'); $whoops->pushHandler($handler); return response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); }
/** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $e) { $whoops = new \Whoops\Run(); $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->addResourcePath(public_path()); $handler->addCustomCss('css/whoops.min.css'); $whoops->pushHandler($handler); return new \Illuminate\Http\Response($whoops->handleException($e)); }
/** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $e) { $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); $whoops->register(); var_dump($e); exit; return new \Illuminate\Http\Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); }
/** * Handle an error with Whoops * * @return string */ public function handle() { $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PlainTextHandler()); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); $whoops->allowQuit(false); $whoops->writeToOutput(false); return $whoops->handleException($this->exception); }
/** * Render an exception using Whoops. * * @param \Exception $exception * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $exception) { $json = new \Whoops\Handler\JsonResponseHandler(); $json->onlyForAjaxRequests(true); $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); $whoops->pushHandler($json); return new \Illuminate\Http\Response($whoops->handleException($exception), $exception->getStatusCode(), $exception->getHeaders()); }
/** * Render an exception using Whoops. * * @param \Illuminate\Http\Request $request * @param \Exception $exception * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops($request, Exception $exception) { $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); if ($request->ajax()) { $whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler()); } return new Response($whoops->handleException($exception), $exception->getStatusCode(), $exception->getHeaders()); }
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); }
/** * 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 (config('app.debug')) { $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); return response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); } return parent::render($request, $e); }
/** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $e) { $whoops = new \Whoops\Run(); $handler = new \Whoops\Handler\PrettyPageHandler(); if ($e instanceof ValidationException) { $handler->addDataTable('Validation Errors', $e->validator->errors()->all()); } $whoops->pushHandler($handler); return new \Illuminate\Http\Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); }
/** * Render an exception into a response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Symfony\Component\HttpFoundation\Response */ public function render($request, Exception $e) { $whoops = new \Whoops\Run(); if ($request->ajax()) { $whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler()); } else { $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); } return new Response($whoops->handleException($e), $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) { if (config('app.debug')) { $whoopsHandler = new \Whoops\Handler\PrettyPageHandler(); $whoopsHandler->setEditor('sublime'); $whoops = new \Whoops\Run(); $whoops->pushHandler($whoopsHandler); return $whoops->handleException($e); } else { return parent::render($request, $e); } }
/** * Render an exception using Whoops. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return Response */ protected function renderExceptionWithWhoops($request, Exception $e) { $whoops = new \Whoops\Run(); if ($request->ajax()) { $whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler()); } elseif (app()->environment() == 'testing') { $whoops->pushHandler(new \Whoops\Handler\PlainTextHandler()); } else { $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); } return new \Illuminate\Http\Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); }
/** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops($request, Exception $e) { if (config('app.debug')) { $whoops = new \Whoops\Run(); $whoops->pushHandler($request->ajax() ? new \Whoops\Handler\JsonResponseHandler() : new \Whoops\Handler\PrettyPageHandler()); $whoops->allowQuit(false); $whoops->writeToOutput(false); return response($whoops->handleException($e), $whoops->sendHttpCode()); } else { return renderHttpExceptionView($e); } }
/** * This method will handle any Exception thrown. * * @param Exception $exception The exception to be handled * * @return void */ public static function handle($exception) { // Verify if the debug level is at least the minDebugLevel if (Configure::read('debug') >= self::$minDebugLevel) { // Debug level is high enough, use the Whoops handler $Whoops = new Whoops\Run(); $Whoops->pushHandler(new Whoops\Handler\PrettyPageHandler()); $Whoops->handleException($exception); } else { // Debug level is too low, fall back to CakePHP default ErrorHandler ErrorHandler::handleException($exception); } }
/** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $e) { $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); /* if (method_exists('getStatisCode', $e)) { return new \Illuminate\Http\Response( $whoops->handleException($e), $e->getStatusCode(), $e->getHeaders() ); }*/ return $whoops->handleException($e); }
/** * 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 ModelNotFoundException) { $e = new NotFoundHttpException($e->getMessage(), $e); } if (config('app.debug')) { $whoops = new \Whoops\Run(); if ($request->ajax()) { $whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler()); } else { $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); } return response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); } return parent::render($request, $e); }
/** * HTTPレスポンスに対応する例外をレンダー * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Illuminate\Http\Response */ public function render($request, Exception $e) { if (config('app.debug') and !$request->ajax()) { $whoos = new \Whoops\Run(); $whoos->pushHandler(new \Whoops\Handler\PrettyPageHandler()); return new \Illuminate\Http\Response($whoos->handleException($e), $e->getStatusCode(), $e->getHeaders()); } else { if ($e->getCode() == Response::HTTP_INTERNAL_SERVER_ERROR) { return response()->view('errors.500', []); } else { if ($e->getCode() == Response::HTTP_NOT_FOUND) { return response()->view('errors.404', []); } } } return parent::render($request, $e); }
/** * Render an exception into a response. * * @param \Illuminate\Http\Request $request * @param \Exception $e * @return \Symfony\Component\HttpFoundation\Response */ public function render($request, Exception $e) { if ($e instanceof ForbiddenException) { return response()->view('errors.forbidden'); } if ($e instanceof NotFoundHttpException) { return response()->view('errors.404'); } if (env('APP_DEBUG', false)) { $whoops = new \Whoops\Run(); if ($request->ajax()) { $whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler()); } else { $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); } return new Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); } }
/** * 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 (config('app.debug')) { $whoops = new \Whoops\Run(); if ($request->ajax()) { $whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler()); } else { $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); } return new Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); } else { $statusCode = $this->isHttpException($exception) ? $exception->getStatusCode() : ''; switch ($statusCode) { case '404': return response()->view('errors/404'); case '503': default: return response()->view('errors/503'); } } return parent::render($request, $exception); }
/** * Render catch esception * * @param \Exception $exception * @param SiteController $controller * @return Response */ public function render(\Exception $exception, SiteController $controller) { if ($exception instanceof IAbort) { return $exception->render($controller); } $controller->view()->buffer()->flush(); $path = $controller->getSiteFolder() . DIRECTORY_SEPARATOR; $path .= $controller->getSiteName() . DIRECTORY_SEPARATOR . 'error' . DIRECTORY_SEPARATOR . '500'; if ($controller->view()->exists($path)) { $params = ['hanlder' => $this, 'error' => $exception]; $content = $controller->view()->render($path, $params); $controller->view()->send($content, '500'); } else { if ($this->config()->isDevMode()) { $run = new \Whoops\Run(); $run->pushHandler(new \Whoops\Handler\PrettyPageHandler()); $run->handleException($exception); } else { echo 'Error on page'; } } return $controller->view()->response(); }
/** * 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) { $debug = config("app.debug"); $debugbar = $debug && config("debugbar.enabled") !== false && !$request->ajax(); if (app()->environment('local')) { if ($request->ajax()) { $handler = new \Whoops\Handler\JsonResponseHandler(); } else { $handler = new \Whoops\Handler\PrettyPageHandler(); $handler->setEditor('sublime'); } $whoops = new \Whoops\Run(); $whoops->pushHandler($handler); $whoops->allowQuit(false); $whoops->writeToOutput(true); $status = 500; $headers = []; if ($e instanceof HttpExceptionInterface) { $status = $e->getStatusCode(); $headers = $e->getHeaders(); } $response = response($whoops->handleException($e), $status, $headers); } else { $response = parent::render($request, $e); } if ($debugbar) { $debugbar = app()->make('debugbar'); $debugbar->boot(); $debugbar->addException($e); $response = $debugbar->modifyResponse($request, $response); } if (Subdomens::is('api')) { $response = Api::addCORSHeaders($response); } return $response; }
/** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $e, $request) { $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler()); return new \Illuminate\Http\Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); }
/** * Render an exception using Whoops. * * @param \Exception $e * @return \Illuminate\Http\Response */ protected function renderExceptionWithWhoops(Exception $e) { $whoops = new \Whoops\Run(); $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); return new SymfonyResponse($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders()); }