Exemplo n.º 1
0
 /**
  * Transform the provided exception.
  *
  * @param \Exception $exception
  *
  * @return \Exception
  */
 public function transform(Exception $exception)
 {
     if ($exception instanceof ExceptionInterface) {
         $exception = new BadRequestHttpException($exception->getMessage());
     }
     return $exception;
 }
Exemplo n.º 2
0
 /**
  * Transform the provided exception.
  *
  * @param \Exception $exception
  *
  * @return \Exception
  */
 public function transform(Exception $exception)
 {
     if ($exception instanceof ExceptionInterface) {
         $exception = new BadRequestHttpException($exception->getMessage());
     } elseif ($exception instanceof ModelNotFoundException) {
         $exception = new NotFoundHttpException('Resource not found.');
     }
     return $exception;
 }
Exemplo n.º 3
0
 /**
  * @param BadRequestHttpException $exception
  *
  * @return Response
  *
  * @throws BadRequestHttpException
  */
 public function createBadRequestResponse(BadRequestHttpException $exception)
 {
     $body = array('success' => false);
     if ($exception instanceof ValidationExceptionSet) {
         $body['error']['global'] = 'You have validation errors';
         $body['error']['errors'] = array();
         foreach ($exception->getExceptions() as $key => $validationException) {
             /** @var ValidationException $validationException */
             $body['error']['errors'][$key] = array('error' => array('message' => $validationException->getMessage(), 'identifier' => $validationException->getIdentifier()), 'definition' => $validationException->getValidator()->getDefinition());
         }
     } else {
         $body['error']['global'] = $exception->getMessage();
     }
     return new JsonResponse($body, Response::HTTP_BAD_REQUEST);
 }
 /**
  * Constructor.
  * @param ConstraintViolationListInterface $violations
  * @param Exception $previous
  * @param int $code
  */
 public function __construct(ConstraintViolationListInterface $violations, Exception $previous = null, $code = 0)
 {
     $message = '';
     /** @var ConstraintViolationInterface $violation */
     foreach ($violations as $violation) {
         $message .= $violation->getPropertyPath() . ' - ' . $violation->getMessage() . PHP_EOL;
     }
     parent::__construct($message, $previous, $code);
 }
Exemplo n.º 5
0
    /**
     * {@inheritdoc}
     */
    public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
    {
        $request->headers->set('X-Php-Ob-Level', ob_get_level());

        try {
            return $this->handleRaw($request, $type);
        } catch (\Exception $e) {
            if ($e instanceof RequestExceptionInterface) {
                $e = new BadRequestHttpException($e->getMessage(), $e);
            }
            if (false === $catch) {
                $this->finishRequest($request, $type);

                throw $e;
            }

            return $this->handleException($e, $request, $type);
        }
    }
Exemplo n.º 6
0
 /**
  * Constructor.
  *
  * @param string     $message  The internal exception message
  * @param \Exception $previous The previous exception
  * @param int        $code     The internal exception code
  */
 public function __construct($message = null, \Exception $previous = null, $code = 0)
 {
     $message = is_null($message) ? 'Malformed JsValidation Request' : $message;
     parent::__construct($message, $previous, $code);
 }
Exemplo n.º 7
0
 /**
  * @param ConstraintViolationList $violations
  */
 public function __construct(ConstraintViolationList $violations)
 {
     parent::__construct("Supplied data is invalid", $this);
     $this->violations = $violations;
 }
Exemplo n.º 8
0
 public function __construct(ConstraintViolationListInterface $violationList, $message = null, $logref = null, \Exception $previous = null, $code = 0)
 {
     parent::__construct($message, $previous, $code);
     $this->violationList = $violationList;
     $this->logref = $logref;
 }
Exemplo n.º 9
0
 /**
  * Constructor
  *
  * @param string     $message Error message
  * @param \Exception $prev    Previous Exception
  */
 public function __construct($message = "Malformed input", $prev = null)
 {
     parent::__construct($message, $prev, Response::HTTP_INTERNAL_SERVER_ERROR);
 }
Exemplo n.º 10
0
 public function __construct(array $errors, $message = null, $logref = null, \Exception $previous = null, $code = 0)
 {
     parent::__construct($message, $previous, $code);
     $this->errors = $errors;
     $this->logref = $logref;
 }
 /**
  * @param string $message, array $form
  */
 public function __construct($message, $form = null)
 {
     parent::__construct($message);
     $this->form = $form;
 }
 /**
  * Constructor
  *
  * @param string $operator RQL operator
  */
 public function __construct($operator)
 {
     parent::__construct(sprintf('RQL operator "%s" is not allowed for this request', $operator));
 }
 public function __construct(Form $form = null)
 {
     parent::__construct((string) $form->getErrors(true, false));
 }
Exemplo n.º 14
0
 /**
  * Constructs a new BrokenPostRequestException.
  *
  * @param string $max_upload_size
  *   The size of the maximum upload size.
  * @param string $message
  *   The internal exception message.
  * @param \Exception $previous
  *   The previous exception.
  * @param int $code
  *   The internal exception code.
  */
 public function __construct($max_upload_size, $message = NULL, \Exception $previous = NULL, $code = 0)
 {
     parent::__construct($message, $previous, $code);
     $this->size = $max_upload_size;
 }
 public function __construct($errors = array())
 {
     parent::__construct("ValidationFailed");
     $this->errors = $errors;
 }
 /**
  * {@inheritdoc}
  */
 public function __construct($message, $code = 0, \Exception $previous = null)
 {
     parent::__construct($message, $previous, $code);
 }
Exemplo n.º 17
0
 public function __construct(FormInterface $form, $message = null, $logref = null, \Exception $previous = null, $code = 0)
 {
     parent::__construct($message, $previous, $code);
     $this->form = $form;
     $this->logref = $logref;
 }
 public function __construct($entityId)
 {
     parent::__construct(sprintf('AuthnRequest received from ServiceProvider with an unknown EntityId: "%s"', $entityId));
 }
Exemplo n.º 19
0
 /**
  * @param \RREST\Error[] $errors   List of errors
  * @param Exception|null $previous
  */
 public function __construct(array $errors, $message = 'Invalid', \Exception $previous = null, $code = 0)
 {
     $this->errors = $errors;
     parent::__construct($message, $previous, $code);
 }
 /**
  * BadRequestConstraintException constructor.
  *
  * @param ConstraintViolationListInterface $violations
  * @param Exception|null                   $previous
  * @param int                              $code
  */
 public function __construct(ConstraintViolationListInterface $violations, Exception $previous = null, $code = 0)
 {
     $this->violations = $violations;
     parent::__construct("Failed constraints", $previous, $code);
 }