2016-09-26 00:22:33 +03:00
|
|
|
<?php
|
|
|
|
function returnError($message, $code){
|
2016-11-09 21:10:40 +03:00
|
|
|
throw new \HttpException($message, $code);
|
2016-09-26 00:22:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function returnClientError($message){
|
2016-11-09 21:10:40 +03:00
|
|
|
returnError($message, 400);
|
2016-09-26 00:22:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function returnServerError($message){
|
2016-11-09 21:10:40 +03:00
|
|
|
returnError($message, 500);
|
2016-09-26 00:22:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function debugMessage($text){
|
2016-11-09 21:10:40 +03:00
|
|
|
if(!file_exists('DEBUG')) {
|
|
|
|
return;
|
|
|
|
}
|
2016-09-26 00:22:33 +03:00
|
|
|
|
2016-11-09 21:10:40 +03:00
|
|
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
|
|
|
|
$calling = $backtrace[2];
|
|
|
|
$message = $calling['file'] . ':'
|
|
|
|
. $calling['line'] . ' class '
|
|
|
|
. $calling['class'] . '->'
|
|
|
|
. $calling['function'] . ' - '
|
|
|
|
. $text;
|
2016-09-26 00:22:33 +03:00
|
|
|
|
2016-11-09 21:10:40 +03:00
|
|
|
error_log($message);
|
2016-09-26 00:22:33 +03:00
|
|
|
}
|