aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-02-13 13:24:26 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-02-13 13:24:26 +0000
commit7a3c2087c5059ea57f3dac59eaa4a0b820e45cf6 (patch)
treed3ee9d6860f267071979d1b9e5c286294991adbf
parent06c9b2931ba80b9023301cd20ce541fdf577814b (diff)
downloadelgg-7a3c2087c5059ea57f3dac59eaa4a0b820e45cf6.tar.gz
elgg-7a3c2087c5059ea57f3dac59eaa4a0b820e45cf6.tar.bz2
Added error handler stuff.
git-svn-id: https://code.elgg.org/elgg/trunk@16 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r--engine/lib/elgglib.php42
1 files changed, 41 insertions, 1 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index ae663af0c..a43fcb407 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -346,5 +346,45 @@
}
return false;
}
-
+
+ /**
+ * PHP Error handler function.
+ * This function acts as a wrapper to catch and report PHP error messages.
+ *
+ * @see http://uk3.php.net/set-error-handler
+ * @param unknown_type $errno
+ * @param unknown_type $errmsg
+ * @param unknown_type $filename
+ * @param unknown_type $linenum
+ * @param unknown_type $vars
+ */
+ public function __php_error_handler($errno, $errmsg, $filename, $linenum, $vars)
+ {
+ $error = date("Y-m-d H:i:s (T)") . ": \"" . $errmsg . "\" in file " . $filename . " (line " . $linenum . ")";
+
+ switch ($errno) {
+ case E_USER_ERROR:
+ error_log("ERROR: " . $error);
+ register_error("ERROR: " . $error);
+
+ // Since this is a fatal error, we want to stop any further execution but do so gracefully.
+ throw new Exception("ERROR: " . $error);
+ break;
+
+ case E_WARNING :
+ case E_USER_WARNING :
+ error_log("WARNING: " . $error);
+ register_error("WARNING: " . $error);
+ break;
+
+ default:
+ error_log("DEBUG: " . $error);
+ register_error("DEBUG: " . $error);
+ }
+ }
+
+
+ // Register the error handler
+ error_reporting(E_ALL);
+ set_error_handler('__php_error_handler');
?> \ No newline at end of file