*
* @return Ansel_Gallery The requested Ansel_Gallery object
* @throws Horde_Exception
+ * @throws InvalidArgumentException
+ *
*/
protected function _getGallery($galleryId = null, $slug = '')
{
}
if (empty($galleryId) && empty($slug)) {
- throw new Horde_Exception(_("No gallery specified"));
+ throw new InvalidArgumentException(_("No gallery specified"));
}
// If we have a slug, use it.
- if (!empty($slug)) {
- $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug);
- } else {
- $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
+ try {
+ if (!empty($slug)) {
+ $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGalleryBySlug($slug);
+ } else {
+ $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId);
+ }
+ } catch (Ansel_Exception $e) {
+ throw new Horde_Exception_NotFound($e->getmessage());
}
+
if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
throw new Horde_Exception(sprintf(_("Access denied to gallery \"%s\"."), $gallery->get('name')));
}
} else {
try {
$this->gallery = $this->_getGallery($gallery_id, $gallery_slug);
- } catch (Horde_Exception $e) {
+ } catch (Exception $e) {
Horde::logMessage($e, 'ERR');
exit;
}