/**
  * @throws HttpException
  */
 protected function handleError()
 {
     $body = (string) $this->response->getBody();
     $code = (int) $this->response->getStatusCode();
     $content = json_decode($body);
     throw new HttpException(isset($content->message) ? $content->message : 'Request not processed.', $code);
 }
Example #2
0
 /**
  * @throws HttpException
  */
 protected function handleError()
 {
     $body = (string) $this->response->getBody();
     $code = (int) $this->response->getStatusCode();
     $content = json_decode($body);
     $error = $content->errors[0];
     throw new HttpException(isset($error) ? $error->description : 'Request not processed.', $code);
 }
 /**
  * Make sure that a different status code throws an exception.
  *
  * @return void
  */
 public function testStatusException()
 {
     $this->response->expects($this->once())->method('getStatusCode')->will($this->returnValue('201'));
     $this->setExpectedException('RuntimeException', 'Unexpected response status code: 201');
     $this->validator->status('200');
 }