當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Handler::convertExceptionToResponse方法代碼示例

本文整理匯總了PHP中Illuminate\Foundation\Exceptions\Handler::convertExceptionToResponse方法的典型用法代碼示例。如果您正苦於以下問題:PHP Handler::convertExceptionToResponse方法的具體用法?PHP Handler::convertExceptionToResponse怎麽用?PHP Handler::convertExceptionToResponse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Foundation\Exceptions\Handler的用法示例。


在下文中一共展示了Handler::convertExceptionToResponse方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: convertExceptionToResponse

 /**
  * 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);
 }
開發者ID:ponko2,項目名稱:laravel-starter-kit,代碼行數:16,代碼來源:Handler.php

示例2: convertExceptionToResponse

 /**
  * @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);
 }
開發者ID:kevinsimard,項目名稱:laravel-app,代碼行數:11,代碼來源:Handler.php

示例3: convertExceptionToResponse

 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);
 }
開發者ID:KNOWARTH,項目名稱:LaravelOnline,代碼行數:9,代碼來源:Handler.php

示例4: convertExceptionToResponse

 /**
  * 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);
 }
開發者ID:jaffle-be,項目名稱:framework,代碼行數:16,代碼來源:Handler.php

示例5: convertExceptionToResponse

 /**
  * 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);
 }
開發者ID:werxe,項目名稱:whoops-laravel,代碼行數:16,代碼來源:WhoopsHandler.php

示例6: convertExceptionToResponse

 /**
  * 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);
 }
開發者ID:rtrzebinski,項目名稱:simple-memorizer-3,代碼行數:17,代碼來源:Handler.php

示例7: _convertExceptionToResponse

 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);
     }
 }
開發者ID:swayok,項目名稱:laravel-extended-errors,代碼行數:18,代碼來源:ExceptionHandler.php

示例8: render

 /**
  * 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);
 }
開發者ID:nukacode,項目名稱:nukacode,代碼行數:47,代碼來源:Handler.php


注:本文中的Illuminate\Foundation\Exceptions\Handler::convertExceptionToResponse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。