Example #1
0
 /**
  * Creates local exception from guzzle request exception, which includes
  * response body.
  *
  * @param  RequestException  $requestException
  *
  * @return void
  * @throws Exceptions\Exception
  */
 protected function throwRequestException(RequestException $requestException)
 {
     $exceptionParts = $this->getRequestExceptionParts($requestException);
     $exception = new Exceptions\Exception($exceptionParts['reason'], $exceptionParts['code'], $requestException);
     $body = $exceptionParts['body'];
     $json = json_decode($body);
     if (json_last_error() == JSON_ERROR_NONE) {
         throw $exception->setResponseBody($json);
     }
     throw $exception->setResponseBody($body);
 }