summaryrefslogtreecommitdiff
path: root/lib/error.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/error.php')
-rw-r--r--lib/error.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/error.php b/lib/error.php
new file mode 100644
index 0000000..ae18f6f
--- /dev/null
+++ b/lib/error.php
@@ -0,0 +1,28 @@
+<?php
+function returnError($message, $code){
+ throw new \HttpException($message, $code);
+}
+
+function returnClientError($message){
+ returnError($message, 400);
+}
+
+function returnServerError($message){
+ returnError($message, 500);
+}
+
+function debugMessage($text){
+ if(!file_exists('DEBUG')) {
+ return;
+ }
+
+ $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
+ $calling = $backtrace[2];
+ $message = $calling['file'] . ':'
+ . $calling['line'] . ' class '
+ . $calling['class'] . '->'
+ . $calling['function'] . ' - '
+ . $text;
+
+ error_log($message);
+}