Inheritance: extends RuntimeExceptio\RuntimeException
Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function checkQuery(EncodingParametersInterface $parameters)
 {
     $errors = new ErrorCollection();
     $this->checkIncludePaths($errors, $parameters);
     $this->checkFieldSets($errors, $parameters);
     $this->checkFiltering($errors, $parameters);
     $this->checkSorting($errors, $parameters);
     $this->checkPaging($errors, $parameters);
     $this->checkUnrecognized($errors, $parameters);
     $errors->count() <= 0 ?: E::throwException(new E($errors, E::HTTP_CODE_BAD_REQUEST));
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function parse(ServerRequestInterface $request)
 {
     $acceptHeader = null;
     $contentTypeHeader = null;
     $method = $request->getMethod();
     try {
         $header = $this->getHeader($request, HeaderInterface::HEADER_CONTENT_TYPE);
         $contentTypeHeader = Header::parse($header, HeaderInterface::HEADER_CONTENT_TYPE);
     } catch (InvalidArgumentException $exception) {
         E::throwException(new E([], E::HTTP_CODE_BAD_REQUEST, $exception));
     }
     try {
         $header = $this->getHeader($request, HeaderInterface::HEADER_ACCEPT);
         $acceptHeader = AcceptHeader::parse($header);
     } catch (InvalidArgumentException $exception) {
         E::throwException(new E([], E::HTTP_CODE_BAD_REQUEST, $exception));
     }
     return $this->factory->createHeaderParameters($method, $acceptHeader, $contentTypeHeader);
 }
 /**
  * ValidationException constructor.
  * @param ErrorInterface|ErrorInterface[]|ErrorCollection $errors
  * @param string|int|null $defaultHttpCode
  * @param Exception|null $previous
  */
 public function __construct($errors, $defaultHttpCode = self::DEFAULT_HTTP_CODE, Exception $previous = null)
 {
     $errors = MutableErrorCollection::cast($errors);
     parent::__construct($errors, $errors->getHttpStatus($defaultHttpCode), $previous);
 }
 /**
  * InvalidJsonException constructor.
  * @param int $jsonError
  * @param string $jsonErrorMessage
  * @param int $defaultHttpCode
  * @param Exception|null $previous
  */
 public function __construct($jsonError, $jsonErrorMessage, $defaultHttpCode = self::HTTP_CODE_BAD_REQUEST, Exception $previous = null)
 {
     parent::__construct([], $defaultHttpCode, $previous);
     $this->jsonError = $jsonError;
     $this->jsonErrorMessage = $jsonErrorMessage;
 }
Ejemplo n.º 5
0
 /**
  * @param array $parameters
  * @param string $name
  *
  * @return string|null
  */
 private function getStringParamOrNull(array $parameters, $name)
 {
     $value = $this->getParamOrNull($parameters, $name);
     $isStringOrNull = $value === null || is_string($value) === true;
     $isStringOrNull === true ?: E::throwException(new E([], E::HTTP_CODE_BAD_REQUEST));
     return $value;
 }