$driverstatus = $DB->driver_installed();
if ($driverstatus !== true) {
- print_error('dbdriverproblem', 'error', '', $driverstatus);
+ throw new dml_exception('dbdriverproblem', $driverstatus);
}
if (debugging('', DEBUG_ALL)) {
fwrite($fp, time());
}
}
- print_error('dbconnectionfailed', 'error', '', $dberr);
+ throw new dml_exception('dbconnectionfailed', $dberr);
}
if (debugging('', DEBUG_ALL)) {
ob_end_clean();
* 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);
+ }
}
}