diff options
Diffstat (limited to 'Postman/Postman-Mail/PostmanSendGridMailEngine.php')
-rw-r--r-- | Postman/Postman-Mail/PostmanSendGridMailEngine.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Postman/Postman-Mail/PostmanSendGridMailEngine.php b/Postman/Postman-Mail/PostmanSendGridMailEngine.php index 28e3c83..eaa5b69 100644 --- a/Postman/Postman-Mail/PostmanSendGridMailEngine.php +++ b/Postman/Postman-Mail/PostmanSendGridMailEngine.php @@ -188,14 +188,16 @@ if ( ! class_exists( 'PostmanSendGridMailEngine' ) ) { $response_body = json_decode( $response->body() ); - if ( isset( $response_body->errors[0]->message ) ) { - $this->transcript = $response_body->errors[0]->message; + if ( isset( $response_body->errors[0]->message ) || $response->statusCode() != 200 ) { + + $e = $response->statusCode() != 200 ? sprintf( __( 'ERROR: Status code is %1$s', Postman::TEXT_DOMAIN ), $response->statusCode() ) : $response_body->errors[0]->message; + $this->transcript = $e; $this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS; $this->transcript .= print_r( $mail, true ); $this->logger->debug( 'Transcript=' . $this->transcript ); - throw new Exception( $response_body->errors[0]->message ); + throw new Exception( $e ); } $this->transcript = print_r( $response->body(), true ); $this->transcript .= PostmanModuleTransport::RAW_MESSAGE_FOLLOWS; |