Skip to content

Commit

Permalink
bug #52095 [Notifier][Sendinblue] Handle error responses without a me…
Browse files Browse the repository at this point in the history
…ssage key (stof)

This PR was merged into the 5.4 branch.

Discussion
----------

[Notifier][Sendinblue] Handle error responses without a message key

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       |
| License       | MIT

During their outage yesterday where the endpoint returned errors with status code 500, there was no `message` key in the json response.
This avoids a notice when the key does not exist. Instead, it uses the full response content, as done when the decoding fails.

Commits
-------

8ae8993 Handle Sendinblue error responses without a message key
  • Loading branch information
nicolas-grekas committed Oct 17, 2023
2 parents bccdccc + 8ae8993 commit 754e482
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
}

if (201 !== $statusCode) {
throw new HttpTransportException('Unable to send an email: '.$result['message'].sprintf(' (code %d).', $statusCode), $response);
throw new HttpTransportException('Unable to send an email: '.($result['message'] ?? $response->getContent(false)).sprintf(' (code %d).', $statusCode), $response);
}

$sentMessage->setMessageId($result['messageId']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function doSend(MessageInterface $message): SentMessage
if (201 !== $statusCode) {
$error = $response->toArray(false);

throw new TransportException('Unable to send the SMS: '.$error['message'], $response);
throw new TransportException('Unable to send the SMS: '.($error['message'] ?? $response->getContent(false)), $response);
}

$success = $response->toArray(false);
Expand Down

0 comments on commit 754e482

Please sign in to comment.