From fd1a792e131006184459a590c4c43f57a9bb3e15 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Mon, 29 Jun 2009 00:34:49 +0000 Subject: [PATCH] themes: MDL-19640 / MDL-19077 remove other references to _print_normal_error --- lib/deprecatedlib.php | 6 ++++-- lib/setuplib.php | 15 ++++++++++++++- lib/upgradelib.php | 29 ++--------------------------- 3 files changed, 20 insertions(+), 30 deletions(-) diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 6bb12ca5dc..c2fca7a794 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -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; } diff --git a/lib/setuplib.php b/lib/setuplib.php index 2677ad94b2..0b9bc8befd 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -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); diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 6cf80286de..ba0ca846a1 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -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)."
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); } /** -- 2.39.5