summaryrefslogtreecommitdiff
path: root/includes
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
parent4145fa13230d25d9978c003a8cccd1b7c2e11aaf (diff)
Add error handling
Diffstat (limited to 'includes')
-rw-r--r--includes/Session.php2
-rw-r--r--includes/error.php25
2 files changed, 26 insertions, 1 deletions
diff --git a/includes/Session.php b/includes/Session.php
index 7951d70..ceaa765 100644
--- a/includes/Session.php
+++ b/includes/Session.php
@@ -54,4 +54,4 @@ class Session
return $result;
}
-} \ No newline at end of file
+}
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');
+?>