A bit better error message when mailbox list can not be generated.
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 18 Jun 2009 22:54:29 +0000 (16:54 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 18 Jun 2009 22:56:09 +0000 (16:56 -0600)
imp/lib/Mailbox.php
imp/lib/Search.php

index 29374dd..7017404 100644 (file)
@@ -308,11 +308,15 @@ class IMP_Mailbox
                 $query->flag('\\deleted', false);
             }
 
-            $this->_sorted = $this->_sortedInfo = array();
-            foreach ($GLOBALS['imp_search']->runSearch($query, $this->_mailbox) as $val) {
-                list($idx, $mbox) = explode(IMP::IDX_SEP, $val);
-                $this->_sorted[] = $idx;
-                $this->_sortedInfo[] = array('m' => $mbox);
+            try {
+                foreach ($GLOBALS['imp_search']->runSearch($query, $this->_mailbox) as $val) {
+                    list($idx, $mbox) = explode(IMP::IDX_SEP, $val);
+                    $this->_sorted[] = $idx;
+                    $this->_sortedInfo[] = array('m' => $mbox);
+                }
+            } catch (Horde_Imap_Client_Exception $e) {
+                $this->_sorted = $this->_sortedInfo = array();
+                $GLOBALS['notification']->push(_("Mailbox listing failed") . ': ' . $e->getMessage(), 'horde.error');
             }
         } else {
             $sortpref = IMP::getSort($this->_mailbox);
@@ -332,6 +336,7 @@ class IMP_Mailbox
                     $this->_sorted = $res['sort'];
                 } catch (Horde_Imap_Client_Exception $e) {
                     $this->_sorted = array();
+                    $GLOBALS['notification']->push(_("Mailbox listing failed") . ': ' . $e->getMessage(), 'horde.error');
                 }
             }
         }
index 342d86c..d03dc3d 100644 (file)
@@ -123,6 +123,7 @@ class IMP_Search
      *                    current ID set in the object).
      *
      * @return array  The sorted list.
+     * @throws Horde_Imap_Client_Exception
      */
     public function runSearch($ob, $id = null)
     {
@@ -148,12 +149,10 @@ class IMP_Search
         }
 
         foreach ($search['folders'] as $val) {
-            try {
-                $results = $GLOBALS['imp_imap']->ob->search($val, $query, array('reverse' => $sortpref['dir'], 'sort' => array($sortpref['by'])));
-                foreach ($results['sort'] as $val2) {
-                    $sorted[] = $val2 . IMP::IDX_SEP . $val;
-                }
-            } catch (Horde_Imap_Client_Exception $e) {}
+            $results = $GLOBALS['imp_imap']->ob->search($val, $query, array('reverse' => $sortpref['dir'], 'sort' => array($sortpref['by'])));
+            foreach ($results['sort'] as $val2) {
+                $sorted[] = $val2 . IMP::IDX_SEP . $val;
+            }
         }
 
         return $sorted;