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

Tweak error message when response is empty #1124

Merged
merged 2 commits into from Sep 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -443,6 +440,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 @@ -452,12 +453,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 @@ -473,10 +469,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