Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function handle(ResponseInterface $response)
 {
     $httpException = new HttpException($response->getStatusCode(), $response->getStatusText());
     // Not 422 contains information about API Error
     if ($response->getStatusCode() == 422) {
         $error = json_decode($response->getContent());
         throw new ApiException(isset($error->Message) ? $error->Message : 'Unprocessable Entity', $httpException);
     }
     throw $httpException;
 }
 /**
  * {@inheritdoc}
  */
 protected function handle(ResponseInterface $response)
 {
     $httpException = new HttpException($response->getStatusCode(), $response->getStatusText());
     // 4xx will containt error information in the body encoded as JSON
     if (!in_array($response->getStatusCode(), range(400, 417))) {
         throw $httpException;
     }
     $error = json_decode($response->getContent());
     throw new ApiException(implode(', ', (array) $error->errors), $httpException);
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  *
  * "You can consider any non-200 HTTP response code an error - the returned data will contain more detailed information"
  */
 protected function handle(ResponseInterface $response)
 {
     $httpException = new HttpException($response->getStatusCode(), $response->getStatusText());
     $error = json_decode($response->getContent());
     throw new ApiException($error->message, $httpException, $error->code);
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 protected function handle(ResponseInterface $response)
 {
     throw new HttpException($response->getStatusCode(), $response->getStatusText());
 }