fix: add error handling for initializer method invocation in InitializerProcessor

- Log errors when initializer method invocation fails
- Re-throw exception after logging
This commit is contained in:
2025-11-03 13:24:47 +01:00
parent a06a73c2f7
commit 1109b0f94b

View File

@@ -167,7 +167,13 @@ final readonly class InitializerProcessor
$factory = function ($container) use ($className, $methodName, $returnType) {
$instance = $container->invoker->invoke(ClassName::create($className), $methodName);
try {
$instance = $container->invoker->invoke(ClassName::create($className), $methodName);
} catch (\Throwable $e) {
$container->get(Logger::class)->error("Failed to invoke initializer method {$methodName} for class {$className}: {$e->getMessage()}");
throw $e;
}
// Wenn das ein Interface ist, registriere auch die konkrete Klasse automatisch
if (interface_exists($returnType)) {