From: Michael J. Rubinsky Date: Thu, 30 Dec 2010 20:37:06 +0000 (-0500) Subject: catch error when searching X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=70324a46b872142bec16459cc62cbff960da8de5;p=horde.git catch error when searching --- diff --git a/ansel/lib/Search/Tag.php b/ansel/lib/Search/Tag.php index 66c4b4635..78b13b6a1 100644 --- a/ansel/lib/Search/Tag.php +++ b/ansel/lib/Search/Tag.php @@ -93,9 +93,6 @@ class Ansel_Search_Tag /** * Fetch the matching resources that should appear on the current page * - * @TODO: Implement an Interface that Ansel_Gallery and Ansel_Image should - * implement that the client search code will use. - * * @return Array of Ansel_Images and Ansel_Galleries */ public function getSlice($page, $perpage) @@ -121,7 +118,11 @@ class Ansel_Search_Tag $count = $perpage - count($galleries); if ($count > 0) { $iresults = array_slice($this->_results['images'], $istart, $count); - $images = count($iresults) ? array_values($GLOBALS['injector']->getInstance('Ansel_Storage')->getImages(array('ids' => $iresults))) : array(); + try { + $images = count($iresults) ? array_values($GLOBALS['injector']->getInstance('Ansel_Storage')->getImages(array('ids' => $iresults))) : array(); + } catch (Horde_Exception_NotFound $e) { + throw new Ansel_Exception($e); + } if (($conf['comments']['allow'] == 'all' || ($conf['comments']['allow'] == 'authenticated' && $GLOBALS['registry']->getAuth())) && $registry->hasMethod('forums/numMessagesBatch')) { diff --git a/ansel/lib/View/Results.php b/ansel/lib/View/Results.php index bb682244c..903179c06 100644 --- a/ansel/lib/View/Results.php +++ b/ansel/lib/View/Results.php @@ -229,7 +229,12 @@ class Ansel_View_Results extends Ansel_View_Base $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage'); // Get the slice of galleries/images to view on this page. - $results = $this->_search->getSlice($this->_page, $this->_perPage); + try { + $results = $this->_search->getSlice($this->_page, $this->_perPage); + } catch (Ansel_Exception $e) { + Horde::logMessage($e->getMessage(), 'ERR'); + return _("An error has occured retrieving the image. Details have been logged."); + } $total = $this->_search->count(); $total = $total['galleries'] + $total['images']; diff --git a/ansel/xppublish.php b/ansel/xppublish.php index a190ebf39..465aa7965 100644 --- a/ansel/xppublish.php +++ b/ansel/xppublish.php @@ -177,7 +177,7 @@ if ($cmd == 'add') { $error = false; } } catch (Ansel_Exception $e) { - $error = _("There was an error accessing the gallery"); + $error = _("There was an error accessing the gallery."); } } if (!$name || $error) {