Don't call Horde::fatal() directly
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 12 Aug 2010 19:31:53 +0000 (13:31 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 12 Aug 2010 19:48:20 +0000 (13:48 -0600)
29 files changed:
agora/forums.php
agora/lib/Messages.php
agora/rss/threads.php
ansel/map_edit.php
beatnik/lib/Driver/ldap2dns.php
gollem/lib/Auth.php
hermes/deliverables.php
horde/docs/CODING_STANDARDS
hylax/compose.php
hylax/lib/Driver.php
hylax/lib/Image.php
hylax/lib/Storage.php
jonah/channels/aggregate.php
luxor/symbol.php
nag/quick.php
nag/scripts/upgrades/2006-04-18_add_creator_and_assignee_fields.php
nag/tasks/index.php
passwd/lib/Driver.php
shout/lib/Driver/Ldap.php
trean/browse.php
trean/lib/Application.php
trean/lib/Bookmarks.php
trean/lib/Trean.php
vilma/lib/Driver.php
vilma/lib/Driver/qmailldap.php
whups/admin/index.php
whups/data.php
whups/search/rss.php
wicked/display.php

index 187a405..2181d6d 100644 (file)
@@ -42,7 +42,7 @@ $forum_start = $forum_page * $forums_per_page;
 /* Get the list of forums. */
 $forums_list = $forums->getForums(0, true, $sort_by, $sort_dir, true, $forum_start, $forums_per_page);
 if ($forums_list instanceof PEAR_Error) {
-    Horde::fatal($forums_list, __FILE__, __LINE__);
+    throw new Horde_Exception($forums_list);
 } elseif (empty($forums_list)) {
     $forums_count = 0;
 } else {
index c0c02f5..534687f 100644 (file)
@@ -2220,7 +2220,8 @@ class Agora_Messages {
     /**
      * Attempts to open a persistent connection to the SQL server.
      *
-     * @return boolean  True on success; exits (Horde::fatal()) on error.
+     * @return boolean  True on success.
+     * @throws Horde_Exception
      */
     private function _connect()
     {
@@ -2233,14 +2234,14 @@ class Agora_Messages {
 
         $this->_write_db = MDB2::factory($this->_params);
         if ($this->_write_db instanceof PEAR_Error) {
-            Horde::fatal($this->_write_db, __FILE__, __LINE__);
+            throw new Horde_Exception($this->_write_db);
         }
 
         if (!empty($params['splitread'])) {
             $params = array_merge($this->_params, $this->_params['read']);
             $this->_db = MDB2::factory($this->_params);
             if ($this->_db instanceof PEAR_Error) {
-                Horde::fatal($this->_db, __FILE__, __LINE__);
+                throw new Horde_Exception($this->_db);
             }
         } else {
             /* Default to the same DB handle for the writer too. */
@@ -2249,7 +2250,7 @@ class Agora_Messages {
 
         $this->_db->loadModule('Extended');
         if ($this->_db instanceof PEAR_Error) {
-            Horde::fatal($this->_db, __FILE__, __LINE__);
+            throw new Horde_Exception($this->_db);
         }
 
         $this->_db->setFetchMode(MDB2_FETCHMODE_ASSOC);
index f95b988..999f791 100644 (file)
@@ -41,18 +41,18 @@ if (!$rss) {
     // Get forum title
     $threads = Agora_Messages::singleton($scope, $forum_id);
     if ($threads instanceof PEAR_Error) {
-        Horde::fatal($threads, __FILE__, __LINE__);
+        throw new Horde_Exception($threads);
     }
     if ($scope == 'agora') {
         $forum_array = $threads->getForum();
         if ($forum_array instanceof PEAR_Error) {
-            Horde::fatal($forum_array, __FILE__, __LINE__);
+            throw new Horde_Exception($forum_array);
         }
         $title = sprintf(_("Threads in %s"), $forum_array['forum_name']);
     } else {
         $title = $registry->callByPackage($scope, 'commentCallback', array($forum_name, 'title'));
         if ($title instanceof PEAR_Error) {
-            Horde::fatal($title, __FILE__, __LINE__);
+            throw new Horde_Exception($title);
         }
         $title = sprintf(_("Comments on %s"), $title);
     }
index d722014..64588c6 100644 (file)
@@ -20,7 +20,7 @@ $image_id = Horde_Util::getFormData('image');
 
 /* Sanity checks, perms etc... */
 if (empty($image_id)) {
-    Horde::fatal(_("An error has occured retrieving the image. Details have been logged."), __FILE__, __LINE__, true);
+    throw new Ansel_Exception(_("An error has occured retrieving the image. Details have been logged."));
 }
 $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id);
 $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery);
index ddb4e56..029d4f5 100644 (file)
@@ -491,7 +491,8 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
      *
      * @access private
      *
-     * @return boolean    True on success; exits (Horde::fatal()) on error.
+     * @return boolean    True on success.
+     * @throws Beatnik_Exception
      *
      * @access private
      */
@@ -506,7 +507,7 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
 
             $this->_LDAP = ldap_connect($this->_params['hostspec'], $port);
             if (!$this->_LDAP) {
-                Horde::fatal("Unable to connect to LDAP server $hostname on $port", __FILE__, __LINE__);
+                throw new Beatnik_Exception("Unable to connect to LDAP server $hostname on $port");
             }
             $res = ldap_set_option($this->_LDAP, LDAP_OPT_PROTOCOL_VERSION, $this->_params['version']);
             if ($res === false) {
index ba9294c..3af1ff1 100644 (file)
@@ -88,7 +88,7 @@ class Gollem_Auth
         // Allocate a global VFS object
         $GLOBALS['gollem_vfs'] = Gollem::getVFSOb($_SESSION['gollem']['backend_key']);
         if (is_a($GLOBALS['gollem_vfs'], 'PEAR_Error')) {
-            Horde::fatal($GLOBALS['gollem_vfs']);
+            throw new Horde_Exception($GLOBALS['gollem_vfs']);
         }
 
         $valid = $GLOBALS['gollem_vfs']->checkCredentials();
index e6721a8..46ebffc 100644 (file)
@@ -69,7 +69,7 @@ if ($vars->exists('deliverable_id') || $vars->exists('new')) {
     if ($vars->exists('deliverable_id')) {
         $deliverable = $hermes->driver->getDeliverableByID($vars->get('deliverable_id'));
         if (is_a($deliverable, 'PEAR_Error')) {
-            Horde::fatal($deliverable, __FILE__, __LINE__);
+            throw new Hermes_Exception($deliverable);
         }
 
         foreach ($deliverable as $name => $value) {
@@ -85,7 +85,7 @@ if ($vars->exists('deliverable_id') || $vars->exists('new')) {
 
     $deliverables = $hermes->driver->listDeliverables(array('client_id' => $vars->get('client_id')));
     if (is_a($deliverables, 'PEAR_Error')) {
-        Horde::fatal($deliverables, __FILE__, __LINE__);
+        throw new Hermes_Exception($deliverables);
     }
 
     $tree = $GLOBALS['injector']->getInstance('Horde_Tree')->getTree('deliverables', 'Javascript');
index 39771bb..40733e1 100644 (file)
@@ -678,7 +678,7 @@ e. Use `array_key_exists()`_ when you want to check if an array key is defined
 
     // Make sure we have a charset parameter. Value could also be null.
     if (!array_key_exists('charset', $params)) {
-        Horde::fatal('Incomplete configuration.');
+        throw new Horde_Exception('Incomplete configuration');
     }
 
 Please note that `array_key_exists()`_ is a performance hit (25%-100%) and
index 82218fe..1d7bd1f 100644 (file)
@@ -24,7 +24,7 @@ foreach ($_covers as $id => $cover) {
 
 $tpl = Horde_Util::getFormData('template', 'default');
 if (empty($_covers[$tpl])) {
-    Horde::fatal(_("The requested Cover Page does not exist."), __FILE__, __LINE__);
+    throw new Horde_Exception(_("The requested Cover Page does not exist."));
 }
 
 /* Load Form Actions */
index c22eb30..30034d7 100644 (file)
@@ -50,9 +50,9 @@ class Hylax_Driver {
         if (class_exists($class)) {
             $hylax = new $class($params);
             return $hylax;
-        } else {
-            Horde::fatal(PEAR::raiseError(sprintf(_("No such backend \"%s\" found"), $driver)), __FILE__, __LINE__);
         }
+
+        throw new Horde_Exception(sprintf(_("No such backend \"%s\" found"), $driver));
     }
 
     /**
index b6a5d4a..af18562 100644 (file)
@@ -119,6 +119,7 @@ class Hylax_Image {
      *
      * @return Hylax_Image  The newly created concrete Hylax_Image instance, or
      *                      false on an error.
+     * @throws Horde_Exception
      */
     function &factory($driver, $params = array())
     {
@@ -128,8 +129,9 @@ class Hylax_Image {
         if (class_exists($class)) {
             $image = &new $class($params);
             return $image;
-        } else {
-            Horde::fatal(PEAR::raiseError(sprintf(_("No such backend \"%s\" found"), $driver)), __FILE__, __LINE__);
+        }
+
+        throw new Horde_Exception(sprintf(_("No such backend \"%s\" found"), $driver));
         }
     }
 
index 7d9ff7e..cba6875 100644 (file)
@@ -28,17 +28,11 @@ class Hylax_Storage {
      * Constructor
      *
      * @param array $params  Any parameters needed for this storage driver.
-     * @throws VFS_Exception
+     * @throws Horde_Exception
      */
     function Hylax_Storage($params)
     {
         $this->_params = $params;
-
-        /* Set up the VFS storage. */
-        if (!isset($GLOBALS['conf']['vfs']['type'])) {
-            Horde::fatal(_("You must configure a VFS backend to use Hylax."), __FILE__, __LINE__);
-        }
-
         $this->_vfs = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs();
     }
 
@@ -145,6 +139,7 @@ class Hylax_Storage {
      *
      * @return Hylax_Storage  The newly created concrete Hylax_Storage
      *                        instance, or false on error.
+     * @throws Horde_Exception
      */
     function &factory($driver, $params = array())
     {
@@ -154,9 +149,9 @@ class Hylax_Storage {
         if (class_exists($class)) {
             $storage = new $class($params);
             return $storage;
-        } else {
-            Horde::fatal(PEAR::raiseError(sprintf(_("No such backend \"%s\" found"), $driver)), __FILE__, __LINE__);
         }
+
+        throw new Horde_Exception(sprintf(_("No such backend \"%s\" found"), $driver));
     }
 
     /**
index feea1ff..436dee5 100644 (file)
@@ -28,8 +28,8 @@ $vars = Horde_Variables::getDefaultVariables();
 /* Set up some variables. */
 $channel_id = $vars->get('channel_id');
 $channel = $news->getChannel($channel_id);
-if (is_a($channel, 'PEAR_Error')) {
-    Horde::fatal($channel, __FILE__, __LINE__);
+if ($channel instanceof PEAR_Error) {
+    throw new Jonah_Exception($channel);
 }
 $channel_name = $channel['channel_name'];
 $ids = preg_split('/:/', $channel['channel_url'], -1, PREG_SPLIT_NO_EMPTY);
index a25c09e..72bcee5 100644 (file)
@@ -19,7 +19,7 @@ $ident = Horde_Util::getFormData('i');
 // Change source if the symbol isn't from the current source.
 $symbolSource = $index->getSourceBySymbol($ident);
 if (!$symbolSource) {
-    Horde::fatal(_("Symbol not found"), __FILE__, __LINE__);
+    throw new Horde_Exception(_("Symbol not found"));
 }
 if ($symbolSource != $sourceid) {
     $source = $sources[$symbolSource];
index 5b6fe3d..08af7ac 100644 (file)
@@ -5,13 +5,15 @@ Horde_Registry::appInit('nag');
 
 if ($quickText = Horde_Util::getPost('quickText')) {
     $result = $registry->tasks->quickAdd($quickText);
-    if ($result) {
-        if (count($result) == 1) {
-            $notification->push(_("Added one task"), 'horde.success');
-        } else {
-            $notification->push(sprintf(_("Added %s tasks"), count($result)), 'horde.success');
-        }
-        Horde::applicationUrl('list.php', true)->redirect();
+    if (!$result) {
+        throw new Nag_Exception($result);
     }
-    Horde::fatal($result);
+
+    if (count($result) == 1) {
+        $notification->push(_("Added one task"), 'horde.success');
+    } else {
+        $notification->push(sprintf(_("Added %s tasks"), count($result)), 'horde.success');
+    }
+
+    Horde::applicationUrl('list.php', true)->redirect();
 }
index 444d769..ba079ed 100755 (executable)
@@ -50,8 +50,8 @@ foreach ($tasklists as $tasklist => $share) {
     while ($task = $tasks->each()) {
         $values = array($owner, $task->id, $task->tasklist);
         $result = $db->execute($sth, $values);
-        if (is_a($result, 'PEAR_Error')) {
-            Horde::fatal($result, __FILE__, __LINE__);
+        if ($result instanceof PEAR_Error) {
+            throw new Nag_Exception($result);
         }
     }
 }
index 45cc4dd..eb3cef4 100644 (file)
@@ -21,8 +21,8 @@ $tasks = Nag::listTasks(
     $prefs->getValue('altsortby'),
     null,
     1);
-if (is_a($tasks, 'PEAR_Error')) {
-    Horde::fatal($tasks);
+if ($tasks instanceof PEAR_Error) {
+    throw new Nag_Exception($tasks);
 }
 
 $search_pattern = '/^' . preg_quote($search, '/') . '/i';
index 9c5aba9..622a719 100644 (file)
@@ -116,6 +116,7 @@ class Passwd_Driver {
      *
      * @return mixed  The newly created concrete Passwd_Driver
      *                instance, or false on an error.
+     * @throws Passwd_Exception
      */
     function factory($driver, $params = array())
     {
@@ -124,9 +125,9 @@ class Passwd_Driver {
         $class = 'Passwd_Driver_' . $driver;
         if (class_exists($class)) {
             return new $class($params);
-        } else {
-            Horde::fatal(PEAR::raiseError(sprintf(_("No such backend \"%s\" found."), $driver)), __FILE__, __LINE__);
         }
+
+        throw new Passwd_Exception(sprintf(_("No such backend \"%s\" found."), $driver));
     }
 
 }
index 2d5d821..084b814 100644 (file)
@@ -436,7 +436,8 @@ class Shout_Driver_Ldap extends Shout_Driver
     /**
      * Attempts to open a connection to the LDAP server.
      *
-     * @return boolean    True on success; exits (Horde::fatal()) on error.
+     * @return boolean    True on success.
+     * @throws Shout_Exception
      *
      * @access private
      */
index f212500..e325b32 100644 (file)
@@ -24,9 +24,9 @@ $folderId = Horde_Util::getFormData('f');
 if (empty($folderId) && $registry->getAuth()) {
     $folderId = $trean_shares->getId($registry->getAuth());
     $folder = &$trean_shares->getFolder($folderId);
-    if (is_a($folder, 'PEAR_Error')) {
+    if ($folder instanceof PEAR_Error) {
         /* Can't redirect back to browse since that would set up a loop. */
-        Horde::fatal($folder, __FILE__, __LINE__, true);
+        throw new Horde_Exception($folder);
     }
 } elseif (empty($folderId)) {
     /* We're accessing Trean as a guest, try to get a folder to browse */
@@ -36,9 +36,9 @@ if (empty($folderId) && $registry->getAuth()) {
     }
 } else {
     $folder = &$trean_shares->getFolder($folderId);
-    if (is_a($folder, 'PEAR_Error')) {
+    if ($folder instanceof PEAR_Error) {
         /* Can't redirect back to browse since that would set up a loop. */
-        Horde::fatal($folder, __FILE__, __LINE__, true);
+        throw new Horde_Exception($folder);
     }
 
     /* Make sure user has permission to view this folder. */
index 53b52ad..12129ba 100644 (file)
@@ -52,8 +52,8 @@ class Trean_Application extends Horde_Registry_Application
 
         // Create db and share instances.
         $GLOBALS['trean_db'] = Trean::getDb();
-        if (is_a($GLOBALS['trean_db'], 'PEAR_Error')) {
-            Horde::fatal($GLOBALS['trean_db'], __FILE__, __LINE__, false);
+        if ($GLOBALS['trean_db'] instanceof PEAR_Error) {
+            throw new Horde_Exception($GLOBALS['trean_db']);
         }
         $GLOBALS['trean_shares'] = new Trean_Bookmarks();
 
index 1187b17..de33b60 100644 (file)
@@ -72,7 +72,7 @@ class Trean_Bookmarks {
         global $conf, $registry;
 
         if (empty($conf['datatree']['driver'])) {
-            Horde::fatal('You must configure a DataTree backend to use Trean.', __FILE__, __LINE__);
+            throw new Horde_Exception('You must configure a DataTree backend to use Trean.');
         }
 
         $driver = $conf['datatree']['driver'];
index 241ce8e..a77b4f0 100644 (file)
@@ -25,8 +25,8 @@ class Trean
             }
             $folder = &$GLOBALS['trean_shares']->newFolder($GLOBALS['registry']->getAuth(), array('name' => sprintf(_("%s's Bookmarks"), $name)));
             $result = $GLOBALS['trean_shares']->addFolder($folder);
-            if (is_a($result, 'PEAR_Error')) {
-                Horde::fatal($result, __FILE__, __LINE__);
+            if ($result instanceof PEAR_Error) {
+                throw new Horde_Exception($result);
             }
         }
     }
index 3a3d921..c0b54bd 100644 (file)
@@ -430,6 +430,7 @@ class Vilma_Driver {
      *
      * @return Vilma_Driver  The newly created concrete Vilma_Driver instance,
      *                       or false on error.
+     * @throws Vilma_Exception
      */
     function factory($driver = null, $params = null)
     {
@@ -446,9 +447,9 @@ class Vilma_Driver {
         $class = 'Vilma_Driver_' . $driver;
         if (class_exists($class)) {
             return new $class($params);
-        } else {
-            Horde::fatal(PEAR::raiseError(sprintf(_("No such backend \"%s\" found"), $driver)), __FILE__, __LINE__);
         }
+
+        throw new Vilma_Exception(sprintf(_("No such backend \"%s\" found"), $driver));
     }
 
     /**
index 85ca5eb..e92a3a3 100644 (file)
@@ -1239,11 +1239,10 @@ class Vilma_Driver_qmailldap extends Vilma_Driver {
 
         $this->_ldap = ldap_connect($this->_ldapparams['ldaphost'], $port);
         if (!$this->_ldap) {
-            Horde::fatal("Unable to connect to LDAP server $hostname on $port",
-                         __FILE__, __LINE__);
-            }
-            $res = ldap_set_option($this->_ldap, LDAP_OPT_PROTOCOL_VERSION,
-                                   $this->_ldapparams['version']);
+            throw new Vilma_Exception("Unable to connect to LDAP server $hostname on $port");
+        }
+        $res = ldap_set_option($this->_ldap, LDAP_OPT_PROTOCOL_VERSION,
+                               $this->_ldapparams['version']);
         if (!$res) {
             return PEAR::raiseError(_("Unable to set LDAP protocol version"));
         }
index 0949ea2..9645b6d 100644 (file)
@@ -91,8 +91,8 @@ case 'addtypestep1form':
         // First, add the type
         $tid = $whups_driver->addType($vars->get('name'),
                                       $vars->get('description'));
-        if (is_a($tid, 'PEAR_Error')) {
-            Horde::fatal($tid, __FILE__, __LINE__);
+        if ($tid instanceof PEAR_Error) {
+            throw new Horde_Exception($tid);
         }
 
         _open();
index 4c84a0f..bb9c48f 100644 (file)
@@ -20,10 +20,10 @@ if (!$GLOBALS['registry']->getAuth()) {
 $tpl = Horde_Util::getFormData('template');
 
 if (empty($_templates[$tpl])) {
-    Horde::fatal(_("The requested template does not exist."), __FILE__, __LINE__);
+    throw new Horde_Exception(_("The requested template does not exist."));
 }
 if ($_templates[$tpl]['type'] != 'searchresults') {
-    Horde::fatal(_("This is not a search results template."), __FILE__, __LINE__);
+    throw new Horde_Exception(_("This is not a search results template."));
 }
 
 // Fetch all unresolved tickets assigned to the current user.
index 8cd3d30..d0da557 100644 (file)
@@ -20,12 +20,12 @@ $form = new SearchForm($vars);
 if ($form->validate($vars, true)) {
     $form->getInfo($vars, $info);
     $tickets = $whups_driver->getTicketsByProperties($info);
-    if (is_a($tickets, 'PEAR_Error')) {
-        Horde::fatal($tickets, __FILE__, __LINE__);
+    if ($tickets instanceof PEAR_Error) {
+        throw new Horde_Exception($tickets);
     }
     Whups::sortTickets($tickets, 'date_updated', 'desc');
 } else {
-    Horde::fatal(_("Invalid search"), __FILE__, __LINE__);
+    throw new Horde_Exception(_("Invalid search"));
 }
 
 $count = 0;
index 17a1fbb..c4f85e3 100644 (file)
@@ -66,7 +66,7 @@ case 'export':
         $notification->push(_("You don't have permission to view this page."),
                             'horde.error');
         if ($page->pageName() == 'WikiHome') {
-            Horde::fatal(_("You don't have permission to view this page."), __FILE__, __LINE__);
+            throw new Horde_Exception(_("You don't have permission to view this page."));
         }
         Wicked::url('WikiHome', true)->redirect();
     }
@@ -110,7 +110,7 @@ if (!$page->allows(WICKED_MODE_DISPLAY)) {
     $notification->push(_("You don't have permission to view this page."),
                         'horde.error');
     if ($page->pageName() == 'WikiHome') {
-        Horde::fatal(_("You don't have permission to view this page."), __FILE__, __LINE__);
+        throw new Horde_Exception(_("You don't have permission to view this page."));
     }
     Wicked::url('WikiHome', true)->redirect();
 }