Shout: Catch startup exceptions
authorBen Klang <ben@alkaloid.net>
Wed, 13 Jan 2010 15:08:47 +0000 (10:08 -0500)
committerBen Klang <ben@alkaloid.net>
Wed, 13 Jan 2010 15:14:10 +0000 (10:14 -0500)
shout/devices.php
shout/extensions.php
shout/lib/Application.php
shout/lib/Driver/Sql.php
shout/lib/Exception.php

index 6c1d00b..3615301 100644 (file)
@@ -98,7 +98,12 @@ default:
 }
 
 // Fetch the (possibly updated) list of extensions
-$devices = $shout->devices->getDevices($context);
+try {
+    $devices = $shout->devices->getDevices($context);
+} catch (Exception $e) {
+    $notification->push($e);
+    $devices = array();
+}
 
 Horde::addScriptFile('stripe.js', 'horde');
 require SHOUT_TEMPLATES . '/common-header.inc';
index b7f9684..6378ba2 100644 (file)
@@ -97,8 +97,14 @@ default:
     $title .= _("List Users");
 }
 
+
 // Fetch the (possibly updated) list of extensions
-$extensions = $shout->extensions->getExtensions($context);
+try {
+    $extensions = $shout->extensions->getExtensions($context);
+} catch (Exception $e) {
+    $notification->push($e);
+    $extensions = array();
+}
 
 Horde::addScriptFile('stripe.js', 'horde');
 Horde::addScriptFile('prototype.js', 'horde');
index 75deba2..7e7a9fa 100644 (file)
@@ -44,11 +44,16 @@ class Shout_Application extends Horde_Registry_Application
             $GLOBALS['registry'] = &Horde_Registry::singleton();
             $registry = &$GLOBALS['registry'];
             try {
-                $registry->pushApp('shout', array('check_perms' => true,
-                                                             'logintasks' => true));
+                $registry->pushApp('shout');
             } catch (Horde_Exception $e) {
                 Horde_Auth::authenticateFailure('shout', $e);
             }
+            $conf = &$GLOBALS['conf'];
+
+            // Notification system.
+            $GLOBALS['notification'] = &Horde_Notification::singleton();
+            $notification = &$GLOBALS['notification'];
+            $notification->attach('status');
 
             define('SHOUT_TEMPLATES', $registry->get('templates'));
 
@@ -63,10 +68,6 @@ class Shout_Application extends Horde_Registry_Application
                 $contexts = false;
             }
 
-            $notification = &Horde_Notification::singleton();
-            $GLOBALS['notification'] = $notification;
-            $notification->attach('status');
-
             if (count($contexts) == 1) {
                 // Default to the user's only context
                 if (!empty($context) && $context != $contexts[0]) {
index 4dead64..7f191a5 100644 (file)
@@ -59,12 +59,12 @@ class Shout_Driver_Sql extends Shout_Driver
         Horde::logMessage($msg, __FILE__, __LINE__, PEAR_LOG_DEBUG);
         $result = $this->_db->query($sql, $vars);
         if ($result instanceof PEAR_Error) {
-            throw Shout_Exception($result);
+            throw new Shout_Exception($result);
         }
 
         $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
         if ($row instanceof PEAR_Error) {
-            throw Shout_Exception($row);
+            throw new Shout_Exception($row);
         }
 
         $contexts = array();
index 301bcf7..9780330 100644 (file)
@@ -1,4 +1,2 @@
 <?php
-class Shout_Exception extends Horde_Exception
-{
-}
\ No newline at end of file
+class Shout_Exception extends Horde_Exception {}