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


PHP Run::handleException方法代码示例

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


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

示例1: display

 /**
  * Display the given exception to the user.
  *
  * @param  \Exception  $exception
  */
 public function display(Exception $exception)
 {
     if (!$this->runningInConsole and !headers_sent()) {
         header('HTTP/1.1 500 Internal Server Error');
     }
     $this->whoops->handleException($exception);
 }
开发者ID:Thomvh,项目名称:turbine,代码行数:12,代码来源:WhoopsDisplayer.php

示例2: __invoke

 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable $next
  *
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     try {
         return $next($request, $response);
     } catch (Exception $e) {
         if ($this->logger) {
             $this->logger->error($e->getMessage(), ['exception' => $e]);
         }
         $type = $this->type($request);
         $response = $response->withHeader('Content-Type', $type);
         try {
             if (method_exists($e, 'getHttpStatus')) {
                 $code = $e->getHttpStatus();
             } else {
                 $code = $e->getCode();
             }
             $response = $response->withStatus($code);
         } catch (InvalidArgumentException $_) {
             // Exception did not contain a valid code
             $response = $response->withStatus(500);
         }
         if ($e instanceof HttpException) {
             $response = $e->withResponse($response);
         }
         $handler = $this->handler($type);
         $this->whoops->pushHandler($handler);
         $body = $this->whoops->handleException($e);
         $response->getBody()->write($body);
         $this->whoops->popHandler();
         return $response;
     }
 }
开发者ID:equip,项目名称:framework,代码行数:39,代码来源:ExceptionHandler.php

示例3: handleException

 /**
  * Handle an exception.
  *
  * Calls on prepareWhoopsHandler() to inject additional data tables into
  * the generated payload, and then injects the response with the result
  * of whoops handling the exception.
  *
  * @param \Exception $exception
  * @param Request $request
  * @param Response $response
  * @return Response
  */
 protected function handleException(\Exception $exception, Request $request, Response $response)
 {
     $this->prepareWhoopsHandler($request);
     $this->whoops->pushHandler($this->whoopsHandler);
     $response->getBody()->write($this->whoops->handleException($exception));
     return $response;
 }
开发者ID:Xerkus,项目名称:zend-expressive,代码行数:19,代码来源:WhoopsErrorHandler.php

示例4: renderExceptionWithWhoops

 /**
  * Render an exception using Whoops.
  *
  * @param  \Exception $e
  * @return \Illuminate\Http\Response
  */
 protected function renderExceptionWithWhoops(Exception $e)
 {
     $whoops = new RunWhoops();
     $whoops->pushHandler(new PrettyPageHandler());
     if ($e instanceof HttpException) {
         return new Response($whoops->handleException($e), $e->getStatusCode(), $e->getHeaders());
     }
     return new Response($whoops->handleException($e));
 }
开发者ID:arszagi,项目名称:laravel,代码行数:15,代码来源:Handler.php

示例5: onException

 /**
  * Handle http exceptions
  *
  * @param UnknownHttpExceptionEvent $event
  */
 public function onException(UnknownHttpExceptionEvent $event)
 {
     if (!$this->environment->equals(Environment::DEVELOPMENT)) {
         return;
     }
     $event->stopPropagation();
     $this->whoops->writeToOutput(false);
     $this->whoops->allowQuit(false);
     $content = $this->whoops->handleException($event->getHttpException());
     $event->getResponse()->setContent($content);
 }
开发者ID:thinframe,项目名称:karma,代码行数:16,代码来源:WhoopsListener.php

示例6: onKernelException

 /**
  * Handle errors thrown in the application.
  *
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $hasUser = $this->session->isStarted() && $this->session->has('authentication');
     if (!$hasUser && !$this->showWhileLoggedOff) {
         return;
     }
     $exception = $event->getException();
     ob_start();
     $this->whoops->handleException($exception);
     $response = ob_get_clean();
     $code = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : Response::HTTP_INTERNAL_SERVER_ERROR;
     $event->setResponse(new Response($response, $code));
 }
开发者ID:jkaan,项目名称:timOnlineBolt,代码行数:18,代码来源:WhoopsListener.php

示例7: appException

 /**
  * 自定义异常处理
  *
  * @param mixed $e 异常对象
  */
 public function appException(&$e)
 {
     if (Cml::$debug) {
         $run = new Run();
         $run->pushHandler(Request::isCli() ? new PlainTextHandler() : new PrettyPageHandler());
         $run->handleException($e);
     } else {
         $error = [];
         $error['message'] = $e->getMessage();
         $trace = $e->getTrace();
         $error['files'][0] = $trace[0];
         if (substr($e->getFile(), -20) !== '\\Tools\\functions.php' || $e->getLine() !== 90) {
             array_unshift($error['files'], ['file' => $e->getFile(), 'line' => $e->getLine(), 'type' => 'throw']);
         }
         //正式环境 只显示‘系统错误’并将错误信息记录到日志
         Log::emergency($error['message'], [$error['files'][0]]);
         $error = [];
         $error['message'] = Lang::get('_CML_ERROR_');
         if (Request::isCli()) {
             \Cml\pd($error);
         } else {
             header('HTTP/1.1 500 Internal Server Error');
             View::getEngine('html')->reset()->assign('error', $error);
             Cml::showSystemTemplate(Config::get('html_exception'));
         }
     }
     exit;
 }
开发者ID:linhecheng,项目名称:cmlphp,代码行数:33,代码来源:Whoops.php

示例8: handleException

 /**
  * Handle an exception.
  *
  * Calls on prepareWhoopsHandler() to inject additional data tables into
  * the generated payload, and then injects the response with the result
  * of whoops handling the exception.
  *
  * @param \Throwable $exception
  * @param Request $request
  * @param Response $response
  * @return Response
  */
 protected function handleException($exception, Request $request, Response $response)
 {
     // Push the whoops handler if any
     if ($this->whoopsHandler !== null) {
         $this->whoops->pushHandler($this->whoopsHandler);
     }
     // Walk through all handlers
     foreach ($this->whoops->getHandlers() as $handler) {
         // Add fancy data for the PrettyPageHandler
         if ($handler instanceof PrettyPageHandler) {
             $this->prepareWhoopsHandler($request, $handler);
         }
     }
     $response->getBody()->write($this->whoops->handleException($exception));
     return $response;
 }
开发者ID:zendframework,项目名称:zend-expressive,代码行数:28,代码来源:WhoopsErrorHandler.php

示例9: debugRender

 /**
  * @param  \Exception $e
  * @return \Illuminate\Http\Response
  */
 protected function debugRender(Exception $e)
 {
     $whoops = new WhoopsRun();
     $whoops->pushHandler(new WhoopsPrettyPageHandler());
     $response = $this->convertExceptionToResponse($e);
     return new HttpResponse($whoops->handleException($e), $response->getStatusCode(), $response->headers);
 }
开发者ID:jbenner-radham,项目名称:v-phoenix,代码行数:11,代码来源:Handler.php

示例10: handleException

 /**
  * @param \Exception|HttpException $exception
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  */
 public function handleException(\Exception $exception)
 {
     $this->app['Logger']->error($exception->getMessage(), ['class' => get_class($exception), 'file' => $exception->getFile(), 'line' => $exception->getLine()]);
     $code = 500;
     if ($exception instanceof HttpException) {
         $code = $exception->getStatusCode();
     }
     if ($this->app['Config']->offsetExists('debug') && $this->app['Config']->offsetGet('debug') === true) {
         ob_start();
         $this->whoops->handleException($exception);
         $html = ob_get_clean();
         $this->writeToOutput($html, $code, $this->contentType);
     } else {
         $this->writeToOutput('whoops something went wrong');
     }
 }
开发者ID:praswicaksono,项目名称:Vinnige,代码行数:21,代码来源:ErrorHandler.php

示例11: onKernelException

 /**
  * Handle errors thrown in the application.
  *
  * Note:
  *   - We don't want to show Whoops! screens for requests that trigger a 404.
  *   - Our priority is set just above Symfony's, as we are giving up and
  *     displaying the error to the user, so that should be a low priority
  *     compared to error handlers that do something else.
  *
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     // We (generally) do not want to show Whoops! screens when the user isn't logged on.
     $hasUser = $this->session->isStarted() && $this->session->has('authentication');
     if (!$hasUser && !$this->showWhileLoggedOff) {
         return;
     }
     // Register Whoops as an error handler
     $this->whoops->register();
     $exception = $event->getException();
     ob_start();
     $this->whoops->handleException($exception);
     $response = ob_get_clean();
     $code = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : Response::HTTP_INTERNAL_SERVER_ERROR;
     $event->setResponse(new Response($response, $code));
 }
开发者ID:robbert-vdh,项目名称:bolt,代码行数:27,代码来源:WhoopsListener.php

示例12: __toString

 /**
  * Convert the view to a rendered string.
  *
  * @return string A string of HTML, e.g. to be `echo`'d.
  */
 public function __toString()
 {
     static $run, $handler;
     if (!isset($run, $handler)) {
         $run = new Run();
         $handler = new PrettyPageHandler();
         $handler->handleUnconditionally(true);
         $run->pushHandler($handler);
         $run->allowQuit(false);
         $run->writeToOutput(false);
         $run->register();
     }
     // __toString cannot throw an exception, so we need to handle those
     // manually to prevent PHP from barfing:
     try {
         return $this->render();
     } catch (Exception $e) {
         self::$didWhoops = true;
         if (!static::$swallowError) {
             return $run->handleException($e);
         } else {
             return static::$swallowError;
         }
     }
 }
开发者ID:monomelodies,项目名称:improse,代码行数:30,代码来源:View.php

示例13: debugException

 /**
  * @param Exception $e
  *
  * @return string
  */
 private function debugException(Exception $e)
 {
     $whoops = new Run();
     $whoops->pushHandler(new PrettyPageHandler());
     $content = $whoops->handleException($e);
     return $content;
 }
开发者ID:wergimity,项目名称:sunnix,代码行数:12,代码来源:Handler.php

示例14: convertExceptionToWhoops

 /**
  * Create a Whoops response for the given exception
  *
  * @param Exception $e
  * @return \Illuminate\Http\Response
  */
 protected function convertExceptionToWhoops(Exception $e)
 {
     $whoops = new Whoops();
     $whoops->pushHandler($this->getWhoopsHandler());
     $statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500;
     $headers = method_exists($e, 'getHeaders') ? $e->getHeaders() : [];
     return response()->make($whoops->handleException($e), $statusCode, $headers);
 }
开发者ID:cheatcodes,项目名称:laravel-whoops,代码行数:14,代码来源:WhoopsExceptionHandler.php

示例15: handleWithWhoops

 protected function handleWithWhoops(Exception $exception)
 {
     $whoops = new Run();
     $whoops->allowQuit(false);
     $whoops->writeToOutput(false);
     $whoops->pushHandler(new PrettyPageHandler());
     return $whoops->handleException($exception);
 }
开发者ID:autarky,项目名称:framework,代码行数:8,代码来源:DefaultErrorHandler.php


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