Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
minor #36170 [Mailer] Use %d instead of %s for error code in error me…
…ssages (fabpot)

This PR was merged into the 4.4 branch.

Discussion
----------

[Mailer] Use %d instead of %s for error code in error messages

| Q             | A
| ------------- | ---
| Branch?       | 4.4 <!-- see below -->
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | n/a <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | n/a

Commits
-------

9c3951e [Mailer] Use %d instead of %s for error code in error messages
  • Loading branch information
fabpot committed Mar 23, 2020
2 parents 8397eb7 + 9c3951e commit cd17611
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
Expand Up @@ -65,7 +65,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e

$result = new \SimpleXMLElement($response->getContent(false));
if (200 !== $response->getStatusCode()) {
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result->Error->Message, $result->Error->Code), $response);
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %d).', $result->Error->Message, $result->Error->Code), $response);
}

$property = $payload['Action'].'Result';
Expand Down
Expand Up @@ -65,7 +65,7 @@ protected function doSendHttp(SentMessage $message): ResponseInterface

$result = new \SimpleXMLElement($response->getContent(false));
if (200 !== $response->getStatusCode()) {
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result->Error->Message, $result->Error->Code), $response);
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %d).', $result->Error->Message, $result->Error->Code), $response);
}

$message->setMessageId($result->SendRawEmailResult->MessageId);
Expand Down
Expand Up @@ -51,10 +51,10 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
$result = $response->toArray(false);
if (200 !== $response->getStatusCode()) {
if ('error' === ($result['status'] ?? false)) {
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result['message'], $result['code']), $response);
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %d).', $result['message'], $result['code']), $response);
}

throw new HttpTransportException(sprintf('Unable to send an email (code %s).', $result['code']), $response);
throw new HttpTransportException(sprintf('Unable to send an email (code %d).', $result['code']), $response);
}

$firstRecipient = reset($result);
Expand Down
Expand Up @@ -58,10 +58,10 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
$result = $response->toArray(false);
if (200 !== $response->getStatusCode()) {
if ('error' === ($result['status'] ?? false)) {
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result['message'], $result['code']), $response);
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %d).', $result['message'], $result['code']), $response);
}

throw new HttpTransportException(sprintf('Unable to send an email (code %s).', $result['code']), $response);
throw new HttpTransportException(sprintf('Unable to send an email (code %d).', $result['code']), $response);
}

$message->setMessageId($result[0]['_id']);
Expand Down
Expand Up @@ -65,10 +65,10 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
$result = $response->toArray(false);
if (200 !== $response->getStatusCode()) {
if ('application/json' === $response->getHeaders(false)['content-type'][0]) {
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result['message'], $response->getStatusCode()), $response);
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %d).', $result['message'], $response->getStatusCode()), $response);
}

throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $response->getContent(false), $response->getStatusCode()), $response);
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %d).', $response->getContent(false), $response->getStatusCode()), $response);
}

$sentMessage->setMessageId($result['id']);
Expand Down
Expand Up @@ -67,10 +67,10 @@ protected function doSendHttp(SentMessage $message): ResponseInterface
$result = $response->toArray(false);
if (200 !== $response->getStatusCode()) {
if ('application/json' === $response->getHeaders(false)['content-type'][0]) {
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result['message'], $response->getStatusCode()), $response);
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %d).', $result['message'], $response->getStatusCode()), $response);
}

throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $response->getContent(false), $response->getStatusCode()), $response);
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %d).', $response->getContent(false), $response->getStatusCode()), $response);
}

$message->setMessageId($result['id']);
Expand Down
Expand Up @@ -54,7 +54,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e

$result = $response->toArray(false);
if (200 !== $response->getStatusCode()) {
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', $result['Message'], $result['ErrorCode']), $response);
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %d).', $result['Message'], $result['ErrorCode']), $response);
}

$sentMessage->setMessageId($result['MessageID']);
Expand Down
Expand Up @@ -53,7 +53,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e
if (202 !== $response->getStatusCode()) {
$errors = $response->toArray(false);

throw new HttpTransportException(sprintf('Unable to send an email: %s (code %s).', implode('; ', array_column($errors['errors'], 'message')), $response->getStatusCode()), $response);
throw new HttpTransportException(sprintf('Unable to send an email: %s (code %d).', implode('; ', array_column($errors['errors'], 'message')), $response->getStatusCode()), $response);
}

$sentMessage->setMessageId($response->getHeaders(false)['x-message-id'][0]);
Expand Down

0 comments on commit cd17611

Please sign in to comment.