From 0bbc02b00649e73f34cf78e67b8b05c69f9c32ad Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Wed, 18 Dec 2013 14:19:39 -0800 Subject: [PATCH] Updated Message class to throw exception when passed nonexistant email ID --- src/Fetch/Message.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Fetch/Message.php b/src/Fetch/Message.php index 9796250..ce37345 100644 --- a/src/Fetch/Message.php +++ b/src/Fetch/Message.php @@ -175,7 +175,8 @@ class Message $this->imapConnection = $mailbox; $this->uid = $messageUniqueId; $this->imapStream = $this->imapConnection->getImapStream(); - $this->loadMessage(); + if($this->loadMessage() !== true) + throw new \RuntimeException('Message with ID ' . $messageUniqueId . ' not found.'); } /** @@ -188,7 +189,8 @@ class Message /* First load the message overview information */ - $messageOverview = $this->getOverview(); + if(!is_object($messageOverview = $this->getOverview())) + return false; $this->subject = $messageOverview->subject; $this->date = strtotime($messageOverview->date); @@ -225,6 +227,8 @@ class Message foreach ($structure->parts as $id => $part) $this->processStructure($part, $id + 1); } + + return true; } /**