Better IMAP error handling when viewing preview
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 20 Oct 2009 19:15:33 +0000 (13:15 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 21 Oct 2009 04:30:02 +0000 (22:30 -0600)
imp/ajax.php

index 8a543ba..1b26a76 100644 (file)
@@ -542,13 +542,21 @@ case 'ShowPreview':
     /* We know we are going to be exclusively dealing with this mailbox, so
      * select it on the IMAP server (saves some STATUS calls). Open R/W to
      * clear the RECENT flag. */
-    $imp_imap->ob()->openMailbox($ptr['key'], Horde_Imap_Client::OPEN_READWRITE);
-
-    $show_msg = new IMP_Views_ShowMessage();
-    $result = (object)$show_msg->showMessage($args);
-    if (isset($result->error)) {
-        $check_uidvalidity = true;
+    try {
+        $imp_imap->ob()->openMailbox($ptr['key'], Horde_Imap_Client::OPEN_READWRITE);
+        $show_msg = new IMP_Views_ShowMessage();
+        $result = (object)$show_msg->showMessage($args);
+        if (isset($result->error)) {
+            $check_uidvalidity = true;
+        }
+    } catch (Horde_Imap_Client_Exception $e) {
+        $result = new stdClass;
+        $result->error = $e->getMessage();
+        $result->errortype = 'horde.error';
+        $result->index = $args['index'];
+        $result->mailbox = $args['mailbox'];
     }
+
     break;
 
 case 'Html2Text':