From 37e4278952a25cb636fa9ab19a9b8695711c0ca5 Mon Sep 17 00:00:00 2001 From: Maarten Date: Thu, 26 Dec 2019 15:41:15 +0100 Subject: [PATCH] Add exception handler for debug disabled --- app/Http/Controllers/HomeController.php | 2 ++ src/Runtime/Exceptions/ExceptionHandler.php | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index f3b3f8a..2d908e7 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -13,6 +13,8 @@ class HomeController extends Controller { public function test() { + a; + return view('index', ['test' => 'Dit is een test']); } diff --git a/src/Runtime/Exceptions/ExceptionHandler.php b/src/Runtime/Exceptions/ExceptionHandler.php index f3d8f07..8b03c75 100644 --- a/src/Runtime/Exceptions/ExceptionHandler.php +++ b/src/Runtime/Exceptions/ExceptionHandler.php @@ -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());