throwException() public static method

public static throwException ( JsonApiException $exception )
$exception JsonApiException
コード例 #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));
 }
コード例 #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);
 }
コード例 #3
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;
 }