コード例 #1
0
 protected function handleWithSymfony(Exception $exception)
 {
     if (!$exception instanceof FlattenException) {
         $exception = FlattenException::create($exception);
     }
     $handler = new ExceptionHandler($this->debug);
     return Response::create($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders());
 }
コード例 #2
0
 public function onSilexError(GetResponseForExceptionEvent $event)
 {
     $handler = new DebugExceptionHandler($this->debug);
     $exception = $event->getException();
     if (!$exception instanceof FlattenException) {
         $exception = FlattenException::create($exception);
     }
     $response = Response::create($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset(ini_get('default_charset'));
     $event->setResponse($response);
 }
コード例 #3
0
ファイル: View.php プロジェクト: despark/ignicms
 public function __toString()
 {
     try {
         return parent::__toString();
         // TODO: Change the autogenerated stub
     } catch (\Exception $exc) {
         ExceptionHelper::logException($exc);
         $eh = new ExceptionHandler(env('APP_DEBUG'));
         die($eh->getHtml($exc));
     }
 }
コード例 #4
0
ファイル: Application.php プロジェクト: dszczer/Minion
    /**
     * @internal
     *
     * Handle errors and exceptions thrown by entire application.
     *
     * @param \Exception $ex   Any exception
     * @param integer    $code HTTP status code
     *
     * @return Response Response to the client with nice error page
     */
    public function minionError(\Exception $ex, $code)
    {
        $handler = new ExceptionHandler($this['debug']);
        $exception = FlattenException::create($ex);
        $response = Response::create($handler->getHtml($exception), $code, $exception->getHeaders())->setCharset(\ini_get('default_charset'));
        if ($this['debug']) {
            return $response;
        } else {
            $content = <<<'HTML'
<!DOCTYPE html>
<html>
    <head><title>Error %d</title></head>
    <body><h1>Error %d occured</h1></body>
</html>
HTML;
            if ($this['minion.useTwig']) {
                $twig = $this['twig'];
                $tpl = "Static/{$code}.html.twig";
                if (!Utils::templateExists($twig, $tpl)) {
                    $content = \str_replace('%d', $code, $content);
                } else {
                    $content = $twig->render($tpl, ['exception' => $ex]);
                }
            } elseif (\file_exists($tpl = Utils::fixPath($this->getRootDir() . "/Static/{$code}.html.php"))) {
                $content = Utils::renderPhpTemplate($tpl, ['exception' => $ex]);
            }
            $response->setStatusCode($code);
            $response->setContent($content);
            return $response;
        }
    }
コード例 #5
0
ファイル: Handler.php プロジェクト: notadd/framework
 /**
  * @param \Exception $exception
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function convertExceptionToResponse(Exception $exception)
 {
     $exception = FlattenException::create($exception);
     $handler = new SymfonyExceptionHandler($this->configuration->get('app.debug'));
     return SymfonyResponse::create($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders());
 }
コード例 #6
0
ファイル: Field.php プロジェクト: despark/ignicms
 /**
  * @return string
  */
 public function __toString()
 {
     try {
         $this->beforeToHtml();
         $html = $this->toHtml();
         $html = $this->afterToHtml($html);
     } catch (\Exception $exc) {
         $eh = new ExceptionHandler(env('APP_DEBUG'));
         die($eh->getHtml($exc));
     }
     return $html;
 }