MDL-16930 dml: exceptions instead of print_error

This commit is contained in:
skodak
2008-10-28 15:21:01 +00:00
parent 655bbf511d
commit 1fe1d10454
2 changed files with 14 additions and 4 deletions
+2 -2
View File
@@ -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();
+12 -2
View File
@@ -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);
}
}
}