/**
  * Display the given exception to the user.
  *
  * @param  \Exception  $exception
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function display(Exception $exception)
 {
     if ($this->returnJson) {
         return new JsonResponse(array('error' => $exception->getMessage(), 'file' => $exception->getFile(), 'line' => $exception->getLine()), 500);
     }
     return $this->symfony->createResponse($exception);
 }
 /**
  * @param Request          $request
  * @param FlattenException $exception
  * @param string           $format
  */
 public function showAction(Request $request, FlattenException $exception, $format)
 {
     $handler = new ExceptionHandler($this->pimple['debug']);
     if ($this->pimple['debug']) {
         return $handler->createResponse($exception);
     }
     $code = $exception->getStatusCode();
     $template = $this->resolve($request, $code, $format);
     if ($template) {
         $contents = $this->pimple['twig']->render($template, array('status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception));
         return new Response($contents, $code);
     }
     return $handler->createResponse($exception);
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function createResponse($exception)
 {
     if ($exception instanceof HttpException) {
         $exception = FlattenException::create($exception, $exception->getCode());
     }
     return parent::createResponse($exception);
 }
Пример #4
0
 public function onSilexError(GetResponseForExceptionEvent $event)
 {
     if (!$this->enabled) {
         return;
     }
     $handler = new DebugExceptionHandler($this->debug);
     $event->setResponse($handler->createResponse($event->getException()));
 }
 public function createResponseBasedOnRequest(Request $request, $exception)
 {
     return parent::createResponse($exception);
 }
 /**
  * Display the given exception to the user.
  *
  * @param  \Exception  $exception
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function display(Exception $exception)
 {
     return $this->symfony->createResponse($exception);
 }
Пример #7
0
 public function testNestedExceptions()
 {
     $handler = new ExceptionHandler(true);
     $response = $handler->createResponse(new \RuntimeException('Foo', null, new \RuntimeException('Bar')));
 }
 /**
  * Return response from CI
  *
  * @param Request $request
  *
  * @return Response
  *
  * @throws \Exception
  */
 public function getResponse(Request $request)
 {
     if (self::$ciLoaded) {
         throw new \Exception('Can not create response for CodeIgniter controller, because another controller was already loaded.');
     }
     self::$ciLoaded = true;
     $this->unsetNoticeErrorLevel();
     $this->setCiPaths($request);
     require_once __DIR__ . '/ci_bootstrap.php';
     try {
         ob_start();
         /*
          * --------------------------------------------------------------------
          * LOAD THE BOOTSTRAP FILE
          * --------------------------------------------------------------------
          *
          * And away we go...
          *
          */
         \ci_bootstrap($this->kernel);
         $response = new Response(ob_get_clean());
     } catch (\Exception $e) {
         ob_get_clean();
         $handler = new ExceptionHandler();
         $response = $handler->createResponse($e);
     }
     return $response;
 }