From 9fe01151af380a8ed6a45dec5191df929af155bd Mon Sep 17 00:00:00 2001 From: Nathan Perkins Date: Mon, 16 Jun 2014 10:38:42 -0400 Subject: [PATCH 1/3] Add HTTP properties to generic error Allows generic HTTP error to accept more detailed information about the response from the server. --- .../Exceptions/GenericHTTPError.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Mailgun/Connection/Exceptions/GenericHTTPError.php b/src/Mailgun/Connection/Exceptions/GenericHTTPError.php index f7cf8c3..b370649 100644 --- a/src/Mailgun/Connection/Exceptions/GenericHTTPError.php +++ b/src/Mailgun/Connection/Exceptions/GenericHTTPError.php @@ -1,6 +1,25 @@ httpResponseCode = $response_code; + $this->httpResponseBody = $response_body; + } + + public function getHttpResponseCode() { + return $this->httpResponseCode; + } + + public function getHttpResponseBody() { + return $this->httpResponseBody; + } +} -?> \ No newline at end of file +?> From ba8e7bda43c35af93bc84ea525f552eceb2e0d3f Mon Sep 17 00:00:00 2001 From: Nathan Perkins Date: Mon, 16 Jun 2014 10:40:18 -0400 Subject: [PATCH 2/3] Throw more detailed generic HTTP error Take advantage of new response code and body properties to allow better logging. --- src/Mailgun/Connection/RestClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mailgun/Connection/RestClient.php b/src/Mailgun/Connection/RestClient.php index 88bd574..7627fa0 100644 --- a/src/Mailgun/Connection/RestClient.php +++ b/src/Mailgun/Connection/RestClient.php @@ -131,7 +131,7 @@ class RestClient{ throw new MissingEndpoint(EXCEPTION_MISSING_ENDPOINT); } else{ - throw new GenericHTTPError(EXCEPTION_GENERIC_HTTP_ERROR); + throw new GenericHTTPError(EXCEPTION_GENERIC_HTTP_ERROR, $httpResponseCode, $responseObj->getBody()); } $result->http_response_code = $httpResponseCode; return $result; @@ -147,4 +147,4 @@ class RestClient{ } } -?> \ No newline at end of file +?> From 5084053ec396356b43c885e37346eeffcb4f48f4 Mon Sep 17 00:00:00 2001 From: Nathan Perkins Date: Mon, 16 Jun 2014 10:48:56 -0400 Subject: [PATCH 3/3] Preserve lack of line endings. --- src/Mailgun/Connection/Exceptions/GenericHTTPError.php | 2 +- src/Mailgun/Connection/RestClient.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mailgun/Connection/Exceptions/GenericHTTPError.php b/src/Mailgun/Connection/Exceptions/GenericHTTPError.php index b370649..199a41f 100644 --- a/src/Mailgun/Connection/Exceptions/GenericHTTPError.php +++ b/src/Mailgun/Connection/Exceptions/GenericHTTPError.php @@ -22,4 +22,4 @@ class GenericHTTPError extends \Exception } } -?> +?> \ No newline at end of file diff --git a/src/Mailgun/Connection/RestClient.php b/src/Mailgun/Connection/RestClient.php index 7627fa0..f07d3dd 100644 --- a/src/Mailgun/Connection/RestClient.php +++ b/src/Mailgun/Connection/RestClient.php @@ -147,4 +147,4 @@ class RestClient{ } } -?> +?> \ No newline at end of file