diff --git a/src/Ouzo/Core/Bootstrap.php b/src/Ouzo/Core/Bootstrap.php index b107c725..f0366a83 100644 --- a/src/Ouzo/Core/Bootstrap.php +++ b/src/Ouzo/Core/Bootstrap.php @@ -10,7 +10,9 @@ use InvalidArgumentException; use Ouzo\Config\ConfigRepository; use Ouzo\ExceptionHandling\DebugErrorHandler; +use Ouzo\ExceptionHandling\DebugExceptionHandler; use Ouzo\ExceptionHandling\ErrorHandler; +use Ouzo\ExceptionHandling\ExceptionHandler; use Ouzo\Injection\Injector; use Ouzo\Injection\InjectorConfig; use Ouzo\Injection\Scope; @@ -109,7 +111,7 @@ public function runApplication(): FrontController private function registerErrorHandlers(): void { if (Config::getValue('debug')) { - (new DebugErrorHandler())->register(); + (new DebugErrorHandler(new DebugExceptionHandler()))->register(); return; } @@ -117,7 +119,7 @@ private function registerErrorHandlers(): void $this->errorHandler->register(); return; } - (new ErrorHandler())->register(); + (new ErrorHandler(new ExceptionHandler()))->register(); } private function includeRoutes(): void diff --git a/src/Ouzo/Core/ExceptionHandling/DebugErrorHandler.php b/src/Ouzo/Core/ExceptionHandling/DebugErrorHandler.php index a7b91e87..99a046fb 100644 --- a/src/Ouzo/Core/ExceptionHandling/DebugErrorHandler.php +++ b/src/Ouzo/Core/ExceptionHandling/DebugErrorHandler.php @@ -11,27 +11,22 @@ class DebugErrorHandler extends ErrorHandler { - protected static function getRun(): Run + public function handleError(int $errorNumber, string $errorString, string $errorFile, int $errorLine): void { - error_reporting(E_ALL); - $run = new Run(); - $run->pushHandler(new PrettyPageHandler()); - $run->pushHandler(new DebugErrorLogHandler()); - return $run; + $this->createWhoops()->handleError($errorNumber, $errorString, $errorFile, $errorLine); } - protected static function getExceptionHandler(): ExceptionHandler + public function handleShutdown(): void { - return new DebugExceptionHandler(); + $this->createWhoops()->handleShutdown(); } - public static function handleError(int $errorNumber, string $errorString, string $errorFile, int $errorLine): void + private function createWhoops(): Run { - self::getRun()->handleError($errorNumber, $errorString, $errorFile, $errorLine); - } - - public static function handleShutdown(): void - { - self::getRun()->handleShutdown(); + error_reporting(E_ALL); + $run = new Run(); + $run->pushHandler(new PrettyPageHandler()); + $run->pushHandler(new DebugErrorLogHandler()); + return $run; } }