Catch exceptions
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 8 Sep 2010 21:06:23 +0000 (17:06 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 8 Sep 2010 21:06:23 +0000 (17:06 -0400)
ansel/lib/Tagger.php
ansel/lib/Widget/Tags.php

index 02690cc..f4c90cf 100644 (file)
@@ -42,7 +42,11 @@ class Ansel_Tagger
             $this->_type_ids = unserialize($ids);
         } else {
             $type_mgr = $GLOBALS['injector']->getInstance('Content_Types_Manager');
-            $types = $type_mgr->ensureTypes(array('gallery', 'image'));
+            try {
+                $types = $type_mgr->ensureTypes(array('gallery', 'image'));
+            } catch (Content_Exception $e) {
+                throw new Ansel_Exception($e);
+            }
             $this->_type_ids = array('gallery' => (int)$types[0],
                                      'image' => (int)$types[1]);
             $GLOBALS['injector']->getInstance('Horde_Cache')->set($key, serialize($this->_type_ids));
index 160e3e6..7a2ac73 100644 (file)
@@ -32,7 +32,11 @@ class Ansel_Widget_Tags extends Ansel_Widget_Base
 
         /* Build the tag widget */
         $html = $this->_htmlBegin();
-        $html .= '<div id="tags">' . $this->_getTagHTML() . '</div>';
+        try {
+            $html .= '<div id="tags">' . $this->_getTagHTML() . '</div>';
+        } catch (Ansel_Exception $e) {
+            return $html . sprintf(_("There was an error fetching tags: %s"), $e->getMessage()) . $this->_htmlEnd();
+        }
         if ($this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
             Horde::startBuffer();
             /* Attach the Ajax action */