当前位置: 首页>>代码示例>>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;未经允许,请勿转载。