diff --git a/README.md b/README.md index 05e8e7d..85c71d4 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ Here are the currently supported services: * [Mailgun](http://www.mailgun.com) (complete) * [Postmark](https://postmarkapp.com) (complete) * [Postage](http://postageapp.com) (complete) -* [Send Grid](http://sendgrid.com) (nearly complete) -* [Spark Post](http://sparkpost.com) (nearly complete) +* [SendGrid](http://sendgrid.com) (nearly complete) +* [SparkPost](http://sparkpost.com) (nearly complete) * [Amazon SES](http://aws.amazon.com/ses) (nearly complete, attachments are missing) * [Mandrill](http://mandrill.com) (complete, but please don't use this party, as Mailchimp / Mandrill do not actively maintain this service) diff --git a/src/Service/SparkPostService.php b/src/Service/SparkPostService.php index 89f7eb5..7e85ef0 100644 --- a/src/Service/SparkPostService.php +++ b/src/Service/SparkPostService.php @@ -524,32 +524,27 @@ private function parseResponse(HttpResponse $response, array $successCodes = []) return $result; } - // There is a 4xx error - if ($response->isClientError()) { - if (isset($result['errors']) && is_array($result['errors'])) { - $message = implode(', ', array_map( - function ($error) { - return $error['message']; - }, - $result['errors'] - )); - } elseif (isset($result['error'])) { - $message = $result['error']; - } else { - $message = 'Unknown error'; - } - - throw new RuntimeException( - sprintf( - 'An error occurred on SparkPost (http code %s), messages: %s', - $response->getStatusCode(), - $message - ) - ); + if (isset($result['errors']) && is_array($result['errors'])) { + $message = implode(', ', array_map( + function ($error) { + return $error['message']; + }, + $result['errors'] + )); + } elseif (isset($result['error'])) { + $message = $result['error']; + } else { + $message = 'Unknown error'; } - // There is a 5xx error - throw new RuntimeException('SparkPost server error, please try again'); + throw new RuntimeException( + sprintf( + 'An error occurred on SparkPost (http code %s), messages: %s', + $response->getStatusCode(), + $message + ), + $response->getStatusCode() + ); } public function previewTemplate(