Example #1
0
 /**
  * Handle an error response exception / object
  * @param BadResponseException $exception
  * @return ErrorException $error_exception
  */
 protected function handleErrorResponse(BadResponseException $exception)
 {
     $response = Response::create($exception->getResponse());
     $errorException = new ErrorException('An error occurred on this request', 0, $exception);
     $errorException->setResponse($response);
     $contentType = $response->getHttpHeader('Content-Type');
     if (!empty($contentType)) {
         $errorClass = $this->getErrorDocumentClass($contentType);
         if (!is_null($errorClass)) {
             $errorDocument = $errorClass::createFromString($response->getBody());
             $errorException->setErrorDocument($errorDocument);
         }
     }
     return $errorException;
 }