当前位置: 首页>>代码示例>>PHP>>正文


PHP ExceptionHandler::getContent方法代码示例

本文整理汇总了PHP中Symfony\Component\Debug\ExceptionHandler::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP ExceptionHandler::getContent方法的具体用法?PHP ExceptionHandler::getContent怎么用?PHP ExceptionHandler::getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Debug\ExceptionHandler的用法示例。


在下文中一共展示了ExceptionHandler::getContent方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * 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);
     }
 }
开发者ID:RustyGamer,项目名称:infinity-next,代码行数:35,代码来源:Handler.php

示例2: sendException

 public function sendException($exception)
 {
     if (!$this->isErrorFromBot()) {
         $recipients = Config::get("error-emailer::to");
         if (isset($recipients['address'])) {
             // this is a single recipient
             if ($recipients['address']) {
                 $recipients = array($recipients);
             } else {
                 $recipients = array();
             }
         }
         if (sizeof($recipients) > 0) {
             if ($exception instanceof FlattenException) {
                 $flattened = $exception;
             } else {
                 $flattened = FlattenException::create($exception);
             }
             $handler = new ExceptionHandler();
             $content = $handler->getContent($flattened);
             $model = array('trace' => $content, 'exception' => $exception, 'flattened' => $flattened);
             Mail::send(Config::get("error-emailer::error_template"), $model, function ($message) use($model, $recipients) {
                 $subject = View::make(Config::get("error-emailer::subject_template"), $model)->render();
                 $message->subject($subject);
                 foreach ($recipients as $to) {
                     $message->to($to['address'], $to['name']);
                 }
             });
         }
     }
 }
开发者ID:Nuwira,项目名称:laravel-error-emailer,代码行数:31,代码来源:ErrorEmailer.php

示例3: render

 /**
  * 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());
 }
开发者ID:rlacerda83,项目名称:lumen-framework,代码行数:14,代码来源:Handler.php

示例4: handleException

 /**
  * 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());
 }
开发者ID:MikeGeorgeff,项目名称:siphon,代码行数:15,代码来源:ExceptionHandler.php

示例5: render

 /**
  * 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);
     }
 }
开发者ID:Cipherwraith,项目名称:infinity-next,代码行数:20,代码来源:Handler.php

示例6: getContent

 public function getContent(FlattenException $exception)
 {
     if ($exception->getStatusCode() == '500') {
         $this->logger->error($exception->getMessage(), ['code' => $exception->getCode(), 'trace' => $exception->getTrace()]);
     }
     switch (true) {
         case 404 === $exception->getStatusCode():
             if (null !== $this->translator) {
                 $title = $this->translator->trans('Sorry, the page you are looking for could not be found.');
             } else {
                 $title = 'Sorry, the page you are looking for could not be found.';
             }
             break;
         case 403 === $exception->getStatusCode():
             if (null !== $this->translator) {
                 $title = $this->translator->trans('Sorry, you do have access to the page you are looking for.');
             } else {
                 $title = 'Sorry, you do have access to the page you are looking for.';
             }
             break;
         case 500 === $exception->getStatusCode():
             if (null !== $this->translator) {
                 $title = $this->translator->trans('Whoops, looks like something went wrong.');
             } else {
                 $title = 'Whoops, looks like something went wrong.';
             }
             break;
         case 503 === $exception->getStatusCode():
             if (null !== $this->translator) {
                 $title = $this->translator->trans('Sorry, site is currently undergoing maintenance, come back soon.');
             } else {
                 $title = 'Sorry, site is currently undergoing maintenance, come back soon.';
             }
             break;
         case isset(Response::$statusTexts[$exception->getStatusCode()]):
             $title = $exception->getStatusCode() . ' : ' . Response::$statusTexts[$exception->getStatusCode()];
             break;
         default:
             if (null !== $this->translator) {
                 $title = $this->translator->trans('Whoops, looks like something went wrong.');
             } else {
                 $title = 'Whoops, looks like something went wrong.';
             }
     }
     $content = parent::getContent($exception);
     $start = strpos($content, '</h1>');
     $content = '<div id="sf-resetcontent" class="sf-reset">' . '<h1><span>' . $title . '</span></h1>' . substr($content, $start + 5);
     return $content;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:49,代码来源:PhraseaExceptionHandler.php

示例7: showAction

 /**
  * Renders the exception panel for the given token.
  *
  * @param string $token The profiler token
  *
  * @return Response A Response instance
  *
  * @throws NotFoundHttpException
  */
 public function showAction($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->twig->getLoader()->exists($template)) {
         $handler = new ExceptionHandler();
         return new Response($handler->getContent($exception), 200, array('Content-Type' => 'text/html'));
     }
     $code = $exception->getStatusCode();
     return Response::create($this->twig->render($template, array('status_code' => $code, 'status_text' => Response::$statusTexts[$code], 'exception' => $exception, 'logger' => null, 'currentContent' => '')), 200, array('Content-Type' => 'text/html'))->setCharset('UTF-8');
 }
开发者ID:vadim2404,项目名称:symfony,代码行数:24,代码来源:ExceptionController.php

示例8: render

 /**
  * 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;
 }
开发者ID:jonathanpmartins,项目名称:lumen-framework,代码行数:25,代码来源:Handler.php

示例9: convertExceptionToResponse

 /**
  * 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());
 }
开发者ID:ziracmo,项目名称:Projet-transversal-2,代码行数:13,代码来源:Handler.php

示例10: render

 /**
  * 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);
 }
开发者ID:tmrwbo,项目名称:infinity-next,代码行数:67,代码来源:Handler.php

示例11: originalConvertExceptionToResponseWithDebugEnabled

 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());
 }
开发者ID:swayok,项目名称:laravel-extended-errors,代码行数:8,代码来源:ExceptionHandler.php


注:本文中的Symfony\Component\Debug\ExceptionHandler::getContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。