summaryrefslogtreecommitdiff
path: root/includes/error.php
diff options
context:
space:
mode:
authorh5p9sl <21267024+h5p9sl@users.noreply.github.com>2021-05-13 22:07:11 -0600
committerh5p9sl <21267024+h5p9sl@users.noreply.github.com>2021-05-14 02:37:13 -0600
commitfe41f57df59c7f2a11d80eaaebf08d3a3a51a6d5 (patch)
tree8917741bbe991d6ddf4f23953309288975f56eb2 /includes/error.php
parent4145fa13230d25d9978c003a8cccd1b7c2e11aaf (diff)
Add error handling
Diffstat (limited to 'includes/error.php')
-rw-r--r--includes/error.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/includes/error.php b/includes/error.php
new file mode 100644
index 0000000..5e33212
--- /dev/null
+++ b/includes/error.php
@@ -0,0 +1,25 @@
+<?php
+function user_notice($message) {
+ echo '<p class="error">'. $message .'</p>';
+}
+
+function handle_error($errno, $errstr, $errfile, $errline) {
+ if (!(error_reporting() & $errno)) {
+ // This error code is not included in error_reporting, so let it fall
+ // through to the standard PHP error handler
+ return false;
+ }
+
+ switch ($errno) {
+ // See https://www.php.net/manual/en/errorfunc.constants.php
+ case E_USER_NOTICE:
+ user_notice($errstr);
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+$old_error_handler = set_error_handler('handle_error');
+?>