diff --git a/lib/dmllib.php b/lib/dmllib.php index d53f52740d3..e193c0b752e 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -89,7 +89,7 @@ function setup_DB() { $driverstatus = $DB->driver_installed(); if ($driverstatus !== true) { - print_error('dbdriverproblem', 'error', '', $driverstatus); + throw new dml_exception('dbdriverproblem', $driverstatus); } if (debugging('', DEBUG_ALL)) { @@ -127,7 +127,7 @@ function setup_DB() { fwrite($fp, time()); } } - print_error('dbconnectionfailed', 'error', '', $dberr); + throw new dml_exception('dbconnectionfailed', $dberr); } if (debugging('', DEBUG_ALL)) { ob_end_clean(); diff --git a/lib/setuplib.php b/lib/setuplib.php index b8c151333a6..1a75ada4ccd 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -63,14 +63,24 @@ class coding_exception extends moodle_exception { * Default exception handler, uncought exceptions are equivalent to using print_error() */ function default_exception_handler($ex) { + global $CFG; + $backtrace = $ex->getTrace(); $place = array('file'=>$ex->getFile(), 'line'=>$ex->getLine(), 'exception'=>get_class($ex)); array_unshift($backtrace, $place); if ($ex instanceof moodle_exception) { - _print_normal_error($ex->errorcode, $ex->module, $ex->a, $ex->link, $backtrace, $ex->debuginfo); + if (!isset($CFG->theme) or !isset($CFG->stylesheets)) { + _print_early_error($ex->errorcode, $ex->module, $ex->a); + } else { + _print_normal_error($ex->errorcode, $ex->module, $ex->a, $ex->link, $backtrace, $ex->debuginfo); + } } else { - _print_normal_error('generalexceptionmessage', 'error', $ex->getMessage(), '', $backtrace); + if (!isset($CFG->theme) or !isset($CFG->stylesheets)) { + _print_early_error('generalexceptionmessage', 'error', $ex->getMessage()); + } else { + _print_normal_error('generalexceptionmessage', 'error', $ex->getMessage(), '', $backtrace); + } } }