fix: wire debug flag into error kernel
This commit is contained in:
@@ -7,12 +7,15 @@ namespace App\Framework\ExceptionHandling;
|
|||||||
use App\Framework\Config\EnvironmentType;
|
use App\Framework\Config\EnvironmentType;
|
||||||
use App\Framework\Console\ConsoleOutput;
|
use App\Framework\Console\ConsoleOutput;
|
||||||
use App\Framework\Context\ExecutionContext;
|
use App\Framework\Context\ExecutionContext;
|
||||||
|
use App\Framework\ErrorAggregation\ErrorAggregatorInterface;
|
||||||
use App\Framework\DI\Container;
|
use App\Framework\DI\Container;
|
||||||
use App\Framework\DI\Initializer;
|
use App\Framework\DI\Initializer;
|
||||||
|
use App\Framework\ExceptionHandling\Audit\ExceptionAuditLogger;
|
||||||
use App\Framework\ExceptionHandling\Context\ExceptionContextProvider;
|
use App\Framework\ExceptionHandling\Context\ExceptionContextProvider;
|
||||||
use App\Framework\ExceptionHandling\Reporter\LogReporter;
|
use App\Framework\ExceptionHandling\Reporter\LogReporter;
|
||||||
use App\Framework\ExceptionHandling\Reporter\Reporter;
|
use App\Framework\ExceptionHandling\Reporter\Reporter;
|
||||||
use App\Framework\ExceptionHandling\Reporter\ReporterRegistry;
|
use App\Framework\ExceptionHandling\Reporter\ReporterRegistry;
|
||||||
|
use App\Framework\ExceptionHandling\RateLimit\ExceptionRateLimiter;
|
||||||
use App\Framework\ExceptionHandling\Strategy\ErrorPolicyResolver;
|
use App\Framework\ExceptionHandling\Strategy\ErrorPolicyResolver;
|
||||||
use App\Framework\Logging\Logger;
|
use App\Framework\Logging\Logger;
|
||||||
use App\Framework\View\Engine;
|
use App\Framework\View\Engine;
|
||||||
@@ -52,8 +55,25 @@ final readonly class ExceptionHandlingInitializer
|
|||||||
isDebugMode: $isDebugMode
|
isDebugMode: $isDebugMode
|
||||||
));
|
));
|
||||||
|
|
||||||
// ErrorKernel - can be autowired (optional dependencies are nullable)
|
// ErrorKernel - bind singleton with explicit debug flag so HTTP renderers respect environment
|
||||||
// No explicit binding needed - container will autowire
|
$container->singleton(ErrorKernel::class, static function (Container $c) use ($isDebugMode, $executionContext, $consoleOutput): ErrorKernel {
|
||||||
|
$errorAggregator = $c->has(ErrorAggregatorInterface::class) ? $c->get(ErrorAggregatorInterface::class) : null;
|
||||||
|
$contextProvider = $c->has(ExceptionContextProvider::class) ? $c->get(ExceptionContextProvider::class) : null;
|
||||||
|
$auditLogger = $c->has(ExceptionAuditLogger::class) ? $c->get(ExceptionAuditLogger::class) : null;
|
||||||
|
$rateLimiter = $c->has(ExceptionRateLimiter::class) ? $c->get(ExceptionRateLimiter::class) : null;
|
||||||
|
|
||||||
|
return new ErrorKernel(
|
||||||
|
rendererFactory: $c->get(ErrorRendererFactory::class),
|
||||||
|
reporter: $c->get(Reporter::class),
|
||||||
|
errorAggregator: $errorAggregator,
|
||||||
|
contextProvider: $contextProvider,
|
||||||
|
auditLogger: $auditLogger,
|
||||||
|
rateLimiter: $rateLimiter,
|
||||||
|
executionContext: $executionContext,
|
||||||
|
consoleOutput: $consoleOutput,
|
||||||
|
isDebugMode: $isDebugMode
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// GlobalExceptionHandler - can be autowired
|
// GlobalExceptionHandler - can be autowired
|
||||||
// No explicit binding needed - container will autowire
|
// No explicit binding needed - container will autowire
|
||||||
|
|||||||
Reference in New Issue
Block a user