Merge branch 'nathanntg-master'

This commit is contained in:
Travis Swientek 2014-11-19 14:23:34 -08:00
commit 529e392386
2 changed files with 23 additions and 2 deletions

View File

@ -1,4 +1,25 @@
<?php <?php
namespace Mailgun\Connection\Exceptions; namespace Mailgun\Connection\Exceptions;
class GenericHTTPError extends \Exception{} class GenericHTTPError extends \Exception
{
protected $httpResponseCode;
protected $httpResponseBody;
public function __construct($message=null, $response_code=null, $response_body=null, $code=0, \Exception $previous=null) {
parent::__construct($message, $code, $previous);
$this->httpResponseCode = $response_code;
$this->httpResponseBody = $response_body;
}
public function getHttpResponseCode() {
return $this->httpResponseCode;
}
public function getHttpResponseBody() {
return $this->httpResponseBody;
}
}
?>

View File

@ -131,7 +131,7 @@ class RestClient{
throw new MissingEndpoint(EXCEPTION_MISSING_ENDPOINT); throw new MissingEndpoint(EXCEPTION_MISSING_ENDPOINT);
} }
else{ else{
throw new GenericHTTPError(EXCEPTION_GENERIC_HTTP_ERROR); throw new GenericHTTPError(EXCEPTION_GENERIC_HTTP_ERROR, $httpResponseCode, $responseObj->getBody());
} }
$result->http_response_code = $httpResponseCode; $result->http_response_code = $httpResponseCode;
return $result; return $result;