Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
bug #1124 Tweak error message when response is empty (fabpot)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 6.1-dev branch (closes #1124).

Discussion
----------

Tweak error message when response is empty

<!-- Please fill in this template according to the PR you're about to submit. -->

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| Doc update?   | no
| BC breaks?    | o
| Deprecations? | no
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT

<!-- Replace this comment by the description of your issue. -->

Commits
-------

2ea9f8c added previous exception to exception
5a6992d tweaked error message when response is empty
  • Loading branch information
fabpot committed Sep 11, 2018
2 parents e71d15b + 2ea9f8c commit 96548d1
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions lib/classes/Swift/Transport/AbstractSmtpTransport.php
Expand Up @@ -188,10 +188,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
}

if (!$reversePath = $this->getReversePath($message)) {
$this->throwException(new Swift_TransportException(
'Cannot send message without a sender address'
)
);
$this->throwException(new Swift_TransportException('Cannot send message without a sender address'));
}

$to = (array) $message->getTo();
Expand Down Expand Up @@ -440,6 +437,10 @@ protected function throwException(Swift_TransportException $e)
/** Throws an Exception if a response code is incorrect */
protected function assertResponseCode($response, $wanted)
{
if (!$response) {
$this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got an empty response'));
}

list($code) = sscanf($response, '%3d');
$valid = (empty($wanted) || in_array($code, $wanted));

Expand All @@ -449,12 +450,7 @@ protected function assertResponseCode($response, $wanted)
}

if (!$valid) {
$this->throwException(
new Swift_TransportException(
'Expected response code '.implode('/', $wanted).' but got code '.
'"'.$code.'", with message "'.$response.'"',
$code)
);
$this->throwException(new Swift_TransportException('Expected response code '.implode('/', $wanted).' but got code "'.$code.'", with message "'.$response.'"', $code));
}
}

Expand All @@ -470,10 +466,7 @@ protected function getFullResponse($seq)
} catch (Swift_TransportException $e) {
$this->throwException($e);
} catch (Swift_IoException $e) {
$this->throwException(
new Swift_TransportException(
$e->getMessage())
);
$this->throwException(new Swift_TransportException($e->getMessage(), 0, $e));
}

return $response;
Expand Down

0 comments on commit 96548d1

Please sign in to comment.