More correct way to report chora errors
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 25 Jan 2011 21:47:19 +0000 (14:47 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 25 Jan 2011 21:47:22 +0000 (14:47 -0700)
Can't call Chora::fatal() from init() since it may be called during
Horde initialization.

12 files changed:
chora/annotate.php
chora/browsedir.php
chora/browsefile.php
chora/co.php
chora/commit.php
chora/cvsgraph.php
chora/diff.php
chora/history.php
chora/lib/Application.php
chora/lib/Chora.php
chora/patchsets.php
chora/stats.php

index 74b634b..d3aa5a9 100644 (file)
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-Horde_Registry::appInit('chora');
+try {
+    Horde_Registry::appInit('chora');
+} catch (Exception $e) {
+    Chora::fatal($e);
+}
 
 /* Spawn the file object. */
 try {
index d6483e7..09c5dfb 100644 (file)
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-Horde_Registry::appInit('chora');
+try {
+    Horde_Registry::appInit('chora');
+} catch (Exception $e) {
+    Chora::fatal($e);
+}
 
 if (!$atdir) {
     require CHORA_BASE . '/browsefile.php';
index 87f9645..da3e4a9 100644 (file)
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-Horde_Registry::appInit('chora');
+try {
+    Horde_Registry::appInit('chora');
+} catch (Exception $e) {
+    Chora::fatal($e);
+}
 
 if ($atdir) {
     require CHORA_BASE . '/browsedir.php';
index e475ddd..8ff009e 100644 (file)
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-Horde_Registry::appInit('chora');
+try {
+    Horde_Registry::appInit('chora');
+} catch (Exception $e) {
+    Chora::fatal($e);
+}
 
 /* If we know we're at a directory, just go to browsedir.php. */
 if ($atdir) {
index e30e64c..ebfea7e 100644 (file)
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-Horde_Registry::appInit('chora');
+try {
+    Horde_Registry::appInit('chora');
+} catch (Exception $e) {
+    Chora::fatal($e);
+}
 
 // Exit if patchset feature is not available.
 if (!$GLOBALS['VC']->hasFeature('patchsets')) {
index 31334f3..6e1bef5 100644 (file)
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-Horde_Registry::appInit('chora');
+try {
+    Horde_Registry::appInit('chora');
+} catch (Exception $e) {
+    Chora::fatal($e);
+}
 
 // Exit if cvsgraph isn't active or it's not supported.
 if (empty($conf['paths']['cvsgraph']) || !$VC->hasFeature('branches')) {
index 934e1a9..2874347 100644 (file)
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-Horde_Registry::appInit('chora');
+try {
+    Horde_Registry::appInit('chora');
+} catch (Exception $e) {
+    Chora::fatal($e);
+}
 
 /* Spawn the repository and file objects */
 try {
index eb3dc29..cbaa954 100644 (file)
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-Horde_Registry::appInit('chora');
+try {
+    Horde_Registry::appInit('chora');
+} catch (Exception $e) {
+    Chora::fatal($e);
+}
 
 // TODO - This currently doesn't work.
 Chora::fatal('History display is currently broken', '500 Internal Server Error');
index 84de361..c943300 100644 (file)
@@ -216,9 +216,6 @@ class Chora_Application extends Horde_Registry_Application
     public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
                                   array $params = array())
     {
-        define('CHORA_ERROR_HANDLER', true);
-
-        $arr = array();
         asort($GLOBALS['sourceroots']);
 
         foreach ($GLOBALS['sourceroots'] as $key => $val) {
index 99aa01d..cc9c0e3 100644 (file)
@@ -76,9 +76,7 @@ class Chora
      */
     static public function fatal($message, $code = null)
     {
-        if (defined('CHORA_ERROR_HANDLER') && constant('CHORA_ERROR_HANDLER')) {
-            return;
-        }
+        global $notification, $registry;
 
         if (is_a($message, 'Horde_Vcs_Exception')) {
             $message = $message->getMessage();
@@ -88,10 +86,13 @@ class Chora
             header('HTTP/1.0 ' . $code);
         }
 
-        $GLOBALS['notification']->push($message, 'horde.error');
-        require $GLOBALS['registry']->get('templates', 'horde') . '/common-header.inc';
+        // Make sure we are in Chora scope.
+        $registry->pushApp('chora');
+
+        $notification->push($message, 'horde.error');
+        require $registry->get('templates', 'horde') . '/common-header.inc';
         require CHORA_TEMPLATES . '/menu.inc';
-        require $GLOBALS['registry']->get('templates', 'horde') . '/common-footer.inc';
+        require $registry->get('templates', 'horde') . '/common-footer.inc';
         exit;
     }
 
index 3493e3d..21b6446 100644 (file)
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-Horde_Registry::appInit('chora');
+try {
+    Horde_Registry::appInit('chora');
+} catch (Exception $e) {
+    Chora::fatal($e);
+}
 
 // Exit if patchset feature is not available.
 if (!$GLOBALS['VC']->hasFeature('patchsets')) {
index 5535558..52edfff 100644 (file)
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-Horde_Registry::appInit('chora');
+try {
+    Horde_Registry::appInit('chora');
+} catch (Exception $e) {
+    Chora::fatal($e);
+}
 
 try {
     $fl = $VC->getFileObject($where);