/**
  * @param Throwable $exception
  */
 public function handle(\Throwable $exception)
 {
     if ($exception instanceof HttpException) {
         http_response_code($exception->getStatusCode());
     }
     if (false === $this->debug) {
         return;
     }
     if (null !== $exception->getPrevious()) {
         $exception = $exception->getPrevious();
     }
     $message = $exception->getMessage();
     $trace = $exception->getTrace();
     array_unshift($trace, array('function' => '', 'file' => $exception->getFile() != null ? $exception->getFile() : null, 'line' => $exception->getLine() != null ? $exception->getLine() : null, 'args' => array()));
     $firstTrace = array_shift($trace);
     $firstTrace['excerpt'] = $this->excerpt($firstTrace['file'], $firstTrace['line']);
     array_unshift($trace, $firstTrace);
     echo $this->templateEngine->render(__DIR__ . '/templates/exception.php', array('message' => $message, 'trace' => $trace));
 }
Пример #2
0
 /**
  * @param string $template
  * @param array  $parameters
  * @param int    $statusCode
  *
  * @return string
  */
 public function render($template, array $parameters = array(), $statusCode = 200)
 {
     $this->statusCode = $statusCode;
     return $this->templateEngine->render($template, $parameters);
 }