From 0feea391cde3063a7d00db4c5099c9d291688c7a Mon Sep 17 00:00:00 2001 From: ArrayIterator Date: Mon, 15 Jul 2024 09:16:16 +0700 Subject: [PATCH] update & add error directly --- src/HttpKernel/BaseKernel.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/HttpKernel/BaseKernel.php b/src/HttpKernel/BaseKernel.php index 2226d9e..89aa251 100644 --- a/src/HttpKernel/BaseKernel.php +++ b/src/HttpKernel/BaseKernel.php @@ -24,6 +24,7 @@ use ArrayAccess\TrayDigita\L10n\Translations\Adapter\Gettext\PoMoAdapter; use ArrayAccess\TrayDigita\L10n\Translations\Adapter\Json\JsonAdapter; use ArrayAccess\TrayDigita\L10n\Translations\Interfaces\TranslatorInterface; +use ArrayAccess\TrayDigita\Middleware\ErrorMiddleware; use ArrayAccess\TrayDigita\Middleware\RoutingMiddleware; use ArrayAccess\TrayDigita\PossibleRoot; use ArrayAccess\TrayDigita\Util\Filter\Consolidation; @@ -837,6 +838,14 @@ final public function init() : static } catch (Throwable) { $debugMiddleware = new DebuggingMiddleware($container); } + try { + $errorMiddleware = ContainerHelper::resolveCallable( + ErrorMiddleware::class, + $container + ); + } catch (Throwable) { + $errorMiddleware = new ErrorMiddleware($container); + } // @dispatch(kernel.initConfig) $manager->dispatch('kernel.initConfig', $this); } finally { @@ -877,7 +886,7 @@ final public function init() : static // registering debug middleware at the first middleware $httpKernel->addMiddleware($debugMiddleware); - + $httpKernel->addDeferredMiddleware($errorMiddleware); return $this; } @@ -929,6 +938,7 @@ public function getRegisteredDirectories(): array return $this->registeredDirectories; } + /** @noinspection PhpUnused */ public function getAppNameSpace(): ?string { return $this->appNameSpace;