]> git.mjollnir.org Git - moodle.git/commitdiff
themes: MDL-19640 / MDL-19077 remove other references to _print_normal_error
authortjhunt <tjhunt>
Mon, 29 Jun 2009 00:34:49 +0000 (00:34 +0000)
committertjhunt <tjhunt>
Mon, 29 Jun 2009 00:34:49 +0000 (00:34 +0000)
lib/deprecatedlib.php
lib/setuplib.php
lib/upgradelib.php

index 6bb12ca5dc5197cba45b5658d921a8a2c86d01eb..c2fca7a7947afa644be4476fd636a9b6e044b911 100644 (file)
@@ -581,7 +581,7 @@ function get_current_group($courseid, $full = false) {
  * @return void Terminates script, does not return!
  */
 function error($message, $link='') {
-    global $UNITTEST;
+    global $UNITTEST, $OUTPUT;
 
     // If unittest running, throw exception instead
     if (!empty($UNITTEST->running)) {
@@ -590,7 +590,9 @@ function error($message, $link='') {
         throw new moodle_exception('notlocalisederrormessage', 'error', $link, $message);
     }
 
-    _print_normal_error('notlocalisederrormessage', 'error', $message, $link, debug_backtrace(), null, true); // show debug warning
+    list($message, $moreinfourl, $link) = prepare_error_message('notlocalisederrormessage', 'error', $link, $message);
+    $OUTPUT->fatal_error($message, $moreinfourl, $link, debug_backtrace(), null, true); // show debug warning
+    die;
 }
 
 
index 2677ad94b20de6ca17784e63a7935b8891af41ca..0b9bc8befd500cec0c5f9710682ad70d9d58ca2d 100644 (file)
@@ -117,8 +117,13 @@ class invalid_state_exception extends moodle_exception {
 
 /**
  * Default exception handler, uncought exceptions are equivalent to using print_error()
+ *
+ * @param Exception $ex 
+ * @param boolean $isupgrade 
+ * @param string $plugin 
+ * Does not return. Terminates execution.
  */
-function default_exception_handler($ex) {
+function default_exception_handler($ex, $isupgrade = false, $plugin = null) {
     global $CFG, $DB, $SCRIPT;
 
     // detect active db transactions, rollback and log as error
@@ -159,6 +164,14 @@ function default_exception_handler($ex) {
 
     list($message, $moreinfourl, $link) = prepare_error_message($errorcode, $module, $link, $a);
 
+    if ($isupgrade) {
+        // First log upgrade error
+        upgrade_log(UPGRADE_LOG_ERROR, $plugin, 'Exception: ' . get_class($ex), $message, $backtrace);
+
+        // Always turn on debugging - admins need to know what is going on
+        $CFG->debug = DEBUG_DEVELOPER;
+    }
+
     if ($earlyerror) {
         // Error found before setup.php finished
         _print_early_error($message, $backtrace, $debuginfo);
index 6cf80286de02b32c382d5d2b915eeba835a09199..ba0ca846a123f545f0be8588e5a2b918ac648b8c 100644 (file)
@@ -627,33 +627,8 @@ function upgrade_plugins_blocks($startcallback, $endcallback, $verbose) {
 /**
  * upgrade logging functions
  */
-function upgrade_handle_exception($ex, $plugin=null) {
-    global $CFG;
-
-    if ($ex instanceof moodle_exception) {
-        $details = get_string($ex->errorcode, $ex->module, $ex->a)."<br />debugging:".$ex->debuginfo;
-    } else {
-        $details = get_string('generalexceptionmessage', 'error', $ex->getMessage());
-    }
-    $info = "Exception: ".get_class($ex);
-    $backtrace = $ex->getTrace();
-    $place = array('file'=>$ex->getFile(), 'line'=>$ex->getLine(), 'exception'=>get_class($ex));
-    array_unshift($backtrace, $place);
-
-    /// first log upgrade error
-    upgrade_log(UPGRADE_LOG_ERROR, $plugin, $info, $details, $backtrace);
-
-    // always turn on debugging - admins need to know what is going on
-    $CFG->debug = DEBUG_DEVELOPER;
-
-    // now print the exception info as usually
-    if ($ex instanceof moodle_exception) {
-        _print_normal_error($ex->errorcode, $ex->module, $ex->a, $ex->link, $backtrace, $ex->debuginfo);
-    } else {
-        _print_normal_error('generalexceptionmessage', 'error', $ex->getMessage(), '', $backtrace);
-    }
-
-    die; // not reached
+function upgrade_handle_exception($ex, $plugin = null) {
+    default_exception_handler($ex, true, $plugin);
 }
 
 /**