Exemplo n.º 1
0
 /**
  * Create a new response from an exception.
  *
  * @param  Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $exception
  * @return \Peakfijn\GetSomeRest\Http\Response
  */
 public static function makeFromException(HttpExceptionInterface $exception)
 {
     $response = new static($exception instanceof RestException ? $exception->getContent() : $exception->getMessage(), $exception->getStatusCode(), $exception->getHeaders());
     $response->setException($exception);
     return $response;
 }
Exemplo n.º 2
0
 /**
  * Response for NotFoundHttpException (Route was not found).
  *
  * @param NotFoundHttpException $exception
  *
  * @return JsonResponse
  */
 private function responseHttpException(HttpExceptionInterface $exception)
 {
     return $this->createResponse($exception->getStatusCode(), $exception->getMessage(), $exception->getHeaders());
 }
Exemplo n.º 3
0
 /**
  * Prepares parameters for HttpExceptionInterface
  *
  * @param HttpExceptionInterface $exception
  */
 protected function prepareHttpException(HttpExceptionInterface $exception)
 {
     $this->sendHttpCode($exception->getStatusCode());
     $this->headers($exception->getHeaders());
 }