/**
  * {inheritDoc}.
  */
 protected function getParameters($currentContent, $code, $exception, DebugLoggerInterface $logger = null, $format = 'html')
 {
     $parameters = parent::getParameters($currentContent, $code, $exception, $logger, $format);
     if ($this->getViewHandler()->isFormatTemplating($format)) {
         $parameters['logger'] = $logger;
     }
     return $parameters;
 }
 protected function getParameters(ViewHandler $viewHandler, $currentContent, $code, $exception, DebugLoggerInterface $logger = null, $format = 'html')
 {
     $parameters = parent::getParameters($viewHandler, $currentContent, $code, $exception, $logger, $format);
     if ($this->container->get('kernel')->isDebug()) {
         $parameters['trace'] = $exception->getTrace();
     }
     return $parameters;
 }
 protected function getParameters(ViewHandler $viewHandler, $currentContent, $code, $exception, DebugLoggerInterface $logger = null, $format = 'html')
 {
     $result = parent::getParameters($viewHandler, $currentContent, $code, $exception, $logger, $format);
     // We are going to check for each Constants defined in VTExceptionInterface, if our $exception (Flatten) is coming from an VTExceptionInterface.
     $refl = new ReflectionClass('VT\\ApiBundle\\Exception\\VTExceptionInterface');
     foreach ($refl->getConstants() as $errorType) {
         if ($exception->getMessage() == $errorType) {
             $exception = new VTExceptionService($errorType);
         }
     }
     // Then, if it wasn't from ARDExceptionService, we use the following fallback
     // This is not extremely precise, but that's ok
     if ($exception instanceof FlattenException) {
         switch ($exception->getStatusCode()) {
             case 400:
                 $exception = new VTExceptionService(VTExceptionInterface::STATUS_INVALID_PARAM);
                 break;
             case 401:
                 $exception = new VTExceptionService(VTExceptionInterface::STATUS_UNAUTHORIZED_CLIENT);
                 break;
             case 403:
                 $exception = new VTExceptionService(VTExceptionInterface::STATUS_RESOURCE_FORBIDDEN);
                 break;
             case 404:
                 $exception = new VTExceptionService(VTExceptionInterface::STATUS_SERVICE_NOT_FOUND);
                 break;
             case 405:
                 $exception = new VTExceptionService(VTExceptionInterface::STATUS_METHOD_NOT_ALLOWED);
                 break;
             case 406:
                 $exception = new VTExceptionService(VTExceptionInterface::STATUS_FORMAT_NOT_SUPPORTED);
                 break;
             case 415:
                 $exception = new VTExceptionService(VTExceptionInterface::STATUS_CONTENT_NOT_SUPPORTED);
                 break;
         }
     }
     if (!$exception instanceof VTExceptionInterface) {
         $result['vt_status'] = VTExceptionInterface::STATUS_INTERNAL_ERROR;
         $result['vt_data'] = array();
     } else {
         $result['vt_status'] = $exception->getResponseStatus();
         $result['vt_data'] = $exception->getServiceResponseData();
     }
     return $result;
 }
 public function __construct(ExceptionWrapperHandlerInterface $exceptionWrapperHandler, FormatNegotiator $formatNegotiator, ViewHandlerInterface $viewHandler, array $exceptionCodes, array $exceptionMessages, $showException, EngineInterface $templating)
 {
     parent::__construct($exceptionWrapperHandler, $formatNegotiator, $viewHandler, $exceptionCodes, $exceptionMessages, $showException);
     $this->templating = $templating;
 }
Exemplo n.º 5
0
 protected function getParameters(ViewHandler $viewHandler, $currentContent, $code, FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
 {
     $defaultParameters = parent::getParameters($viewHandler, $currentContent, $code, $exception, $logger, $format);
     $parameters = array('errors' => array(array('code' => $defaultParameters['status_code'], 'message' => $defaultParameters['message'])));
     return $parameters;
 }
 /**
  * @inheritdoc
  */
 protected function createView(\Exception $exception, $code, array $templateData, Request $request, $showException)
 {
     $templateData['status_code'] = $exception->getCode() ?: $templateData['status_code'];
     return parent::createView($exception, $code, $templateData, $request, $showException);
 }
 /**
  * {@inheritdoc}
  */
 public function showAction(Request $request, $exception, DebugLoggerInterface $logger = null)
 {
     $request->attributes->set('showException', true);
     return parent::showAction($request, $exception, $logger);
 }