]> git.mjollnir.org Git - moodle.git/commitdiff
Added a simple moodle_error_hendler function I'm playing with
authormoodler <moodler>
Wed, 13 Sep 2006 08:23:30 +0000 (08:23 +0000)
committermoodler <moodler>
Wed, 13 Sep 2006 08:23:30 +0000 (08:23 +0000)
lib/weblib.php

index 9c7a5577ae127dceeb081c4fa89b4e6578376957..a35301a5b2a4468f0cfbd144e6dc6c17fdb4dcff 100644 (file)
@@ -5217,6 +5217,41 @@ function page_doc_link($text='', $iconpath='') {
     return $str;
 }
 
+function moodle_error_handler($errno, $errstr, $errfile, $errline) {
+    global $CFG;
+
+    switch ($errno) {
+        case E_USER_ERROR:
+            if ($CFG->debug > E_USER_ERROR) {
+                echo "<b>FATAL ERROR:</b> [$errno] $errstr<br />\n";
+                echo "  Fatal error in line $errline of file $errfile";
+                echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
+                echo "Stack trace...<br />\n";
+                if (function_exists('debug_print_backtrace')) {
+                    debug_print_backtrace();
+                } else {
+                    print_object(debug_backtrace());
+                }
+                echo "<p>Aborting...</p>\n";
+                exit(1);
+            }
+            break;
+        case E_USER_WARNING:
+            if ($CFG->debug > E_USER_WARNING) {
+                echo "<b>WARNING</b> [$errno] $errstr<br />\n";
+            }
+            break;
+        case E_USER_NOTICE:
+            if ($CFG->debug > E_USER_NOTICE) {
+                echo "<b>NOTICE</b> [$errno] $errstr<br />\n";
+            }
+            break;
+        default:
+            echo "Unknown error type: [$errno] $errstr<br />\n";
+            break;
+    }
+}
+
 
 // vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
 ?>