Skip to content

Commit

Permalink
Merge pull request #8 from integratedexperts/patch-1
Browse files Browse the repository at this point in the history
Added catching of the errors for Mailcatcher if HTML or Plain version of the message is not provided.
  • Loading branch information
tyler43636 authored May 30, 2018
2 parents 414467f + 093df70 commit 39a5e13
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/Driver/MailCatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,23 @@ public function deleteMessages()
*/
private function mapToMessage($message)
{
$html = $this->client->get("/messages/{$message['id']}.html")
->getBody()
->getContents();
try {
$html = $this->client->get("/messages/{$message['id']}.html")
->getBody()
->getContents();
}
catch (\Exception $exception) {
$html = sprintf('Error while retrieving HTML message "%s": %s', $message['id'], $exception->getMessage());
}

$text = $this->client->get("/messages/{$message['id']}.plain")
->getBody()
->getContents();
try {
$text = $this->client->get("/messages/{$message['id']}.plain")
->getBody()
->getContents();
}
catch (\Exception $exception) {
$text = sprintf('Error while retrieving Plain message "%s": %s', $message['id'], $exception->getMessage());
}

return MessageFactory::fromMailCatcher($message, $html, $text);
}
Expand Down

0 comments on commit 39a5e13

Please sign in to comment.