MDL-16930 dml: exceptions instead of print_error
This commit is contained in:
+2
-2
@@ -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
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user