Catch exceptions from API call.
authorJan Schneider <jan@horde.org>
Fri, 21 Jan 2011 14:16:16 +0000 (15:16 +0100)
committerJan Schneider <jan@horde.org>
Fri, 21 Jan 2011 17:16:29 +0000 (18:16 +0100)
turba/lib/Driver/Favourites.php

index 2468cf1..63e1fe6 100644 (file)
@@ -131,7 +131,18 @@ class Turba_Driver_Favourites extends Turba_Driver
             throw new Turba_Exception(_("No source for favourite recipients exists."));
         }
 
-        $addresses = $registry->call('contacts/favouriteRecipients', array($this->_params['limit']));
+        try {
+            $addresses = $registry->call('contacts/favouriteRecipients', array($this->_params['limit']));
+        } catch (Horde_Exception $e) {
+            if ($e->getCode() == Horde_Registry::AUTH_FAILURE ||
+                $e->getCode() == Horde_Registry::NOT_ACTIVE ||
+                $e->getCode() == Horde_Registry::PERMISSION_DENIED) {
+                return array();
+            }
+            throw new Turba_Exception($e);
+        } catch (Exception $e) {
+            throw new Turba_Exception($e);
+        }
 
         $addressbook = array();
         foreach ($addresses as $address) {