diff --git a/src/Mailgun/Exception/HttpClientException.php b/src/Mailgun/Exception/HttpClientException.php index 1dedffc..140334b 100644 --- a/src/Mailgun/Exception/HttpClientException.php +++ b/src/Mailgun/Exception/HttpClientException.php @@ -27,6 +27,11 @@ final class HttpClientException extends \RuntimeException implements Exception */ private $responseBody; + /** + * @var int + */ + private $responseCode; + /** * @param string $message * @param int $code @@ -38,6 +43,7 @@ final class HttpClientException extends \RuntimeException implements Exception if ($response) { $this->response = $response; + $this->responseCode = $response->getStatusCode(); $body = $response->getBody()->__toString(); if (strpos($response->getHeaderLine('Content-Type'), 'application/json') !== 0) { $this->responseBody['message'] = $body; @@ -82,4 +88,12 @@ final class HttpClientException extends \RuntimeException implements Exception { return $this->responseBody; } + + /** + * @return int + */ + public function getResponseCode() + { + return $this->responseCode; + } } diff --git a/src/Mailgun/Exception/HttpServerException.php b/src/Mailgun/Exception/HttpServerException.php index 3d5aa27..bb1bf52 100644 --- a/src/Mailgun/Exception/HttpServerException.php +++ b/src/Mailgun/Exception/HttpServerException.php @@ -18,12 +18,12 @@ final class HttpServerException extends \RuntimeException implements Exception { public static function serverError($httpStatus = 500) { - return new self('An unexpected error occurred at Mailgun\'s servers. Try again later and contact support of the error sill exists.', $httpStatus); + return new self('An unexpected error occurred at Mailgun\'s servers. Try again later and contact support if the error sill exists.', $httpStatus); } public static function networkError(\Exception $previous) { - return new self('Mailgun\'s servers was unreachable.', 0, $previous); + return new self('Mailgun\'s servers are currently unreachable.', 0, $previous); } public static function unknownHttpResponseCode($code)