]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16930 dml: exceptions instead of print_error
authorskodak <skodak>
Tue, 28 Oct 2008 15:21:01 +0000 (15:21 +0000)
committerskodak <skodak>
Tue, 28 Oct 2008 15:21:01 +0000 (15:21 +0000)
lib/dmllib.php
lib/setuplib.php

index d53f52740d3e974d5034f51b862a1e231560ebb0..e193c0b752e9a3dcb073ffd97e4db018de8e6afe 100644 (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();
index b8c151333a6cbb7f9b7b2d2cfde2a7f7dbb6f886..1a75ada4ccdc1c3331375d50b168db2c58473cb9 100644 (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);
+        }
     }
 }