/** * 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; }
/** * 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; }
/** * @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); }
/** * {@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); } }
/** * 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); }
/** * @param ConstraintViolationList $violations */ public function __construct(ConstraintViolationList $violations) { parent::__construct("Supplied data is invalid", $this); $this->violations = $violations; }
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; }
/** * 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); }
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)); }
/** * 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); }
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)); }
/** * @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); }