aboutsummaryrefslogtreecommitdiff
path: root/lib/error.php
blob: ae18f6ff70e662df5f58779346f72df21181aeca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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);
}