Add exception handler for debug disabled

This commit is contained in:
Maarten 2019-12-26 15:41:15 +01:00
parent e516e6cbdf
commit 37e4278952
2 changed files with 16 additions and 1 deletions

View file

@ -13,6 +13,8 @@ class HomeController extends Controller {
public function test()
{
a;
return view('index', ['test' => 'Dit is een test']);
}

View file

@ -2,6 +2,7 @@
namespace Runtime\Exceptions;
use Whoops\Handler\Handler;
use Whoops\Handler\JsonResponseHandler;
use Whoops\Handler\PlainTextHandler;
use Whoops\Run;
@ -38,7 +39,19 @@ class ExceptionHandler {
public static function register()
{
self::$handler = new Run();
self::$handler->pushHandler(new PrettyPageHandler());
$debug = false; //TODO: Get from config
if($debug === false) {
self::$handler->pushHandler(function(\Exception $exception, $inspector, $run) {
echo 'An error has occured';
//TODO: Add proper 500 error page
return Handler::DONE;
});
}
else {
self::$handler->pushHandler(new PrettyPageHandler());
}
if (Misc::isAjaxRequest()){
self::$handler->pushHandler(new JsonResponseHandler());