mirror of
https://git.steelants.cz/SH/PHP_SMART_HOME_V3.git
synced 2026-10-11 17:54:34 +00:00
Api exeption handler
This commit is contained in:
1 parent
8300e47b76
commit
119149bf5e
2 files changed
+11
-8
No files matched your search
+9
-6
@@ -34,12 +34,15 @@ spl_autoload_register("Autoloader::ClassLoader");
|
||||
Autoloader::setRoot('/var/www/dev.steelants.cz/vasek/home-update/');
|
||||
|
||||
class ErrorHandler {
|
||||
static function exception($exception){
|
||||
error_log($exception);
|
||||
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, $exception->getCode());
|
||||
echo '<h1>Oops!</h1><p>Something went wrong!</p>';
|
||||
exit;
|
||||
}
|
||||
static function exception($exception){
|
||||
error_log($exception);
|
||||
http_response_code($exception->getCode());
|
||||
$message = [
|
||||
'code' => $exception->getCode(),
|
||||
'message' => $exception->getMessage(),
|
||||
];
|
||||
echo json_encode($message);
|
||||
}
|
||||
}
|
||||
set_exception_handler("ErrorHandler::exception");
|
||||
|
||||
|
||||
Reference in new issue
Block a user