fix: wire debug flag into error kernel
All checks were successful
Test Runner / test-php (push) Successful in 27s
Deploy Application / deploy (push) Successful in 59s
Test Runner / test-basic (push) Successful in 6s

This commit is contained in:
2025-11-25 04:36:19 +01:00
parent 4309ea7972
commit f9063aa151

View File

@@ -7,12 +7,15 @@ namespace App\Framework\ExceptionHandling;
use App\Framework\Config\EnvironmentType;
use App\Framework\Console\ConsoleOutput;
use App\Framework\Context\ExecutionContext;
use App\Framework\ErrorAggregation\ErrorAggregatorInterface;
use App\Framework\DI\Container;
use App\Framework\DI\Initializer;
use App\Framework\ExceptionHandling\Audit\ExceptionAuditLogger;
use App\Framework\ExceptionHandling\Context\ExceptionContextProvider;
use App\Framework\ExceptionHandling\Reporter\LogReporter;
use App\Framework\ExceptionHandling\Reporter\Reporter;
use App\Framework\ExceptionHandling\Reporter\ReporterRegistry;
use App\Framework\ExceptionHandling\RateLimit\ExceptionRateLimiter;
use App\Framework\ExceptionHandling\Strategy\ErrorPolicyResolver;
use App\Framework\Logging\Logger;
use App\Framework\View\Engine;
@@ -52,8 +55,25 @@ final readonly class ExceptionHandlingInitializer
isDebugMode: $isDebugMode
));
// ErrorKernel - can be autowired (optional dependencies are nullable)
// No explicit binding needed - container will autowire
// ErrorKernel - bind singleton with explicit debug flag so HTTP renderers respect environment
$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
// No explicit binding needed - container will autowire