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:
@@ -167,7 +167,13 @@ final readonly class InitializerProcessor
|
|||||||
|
|
||||||
$factory = function ($container) use ($className, $methodName, $returnType) {
|
$factory = function ($container) use ($className, $methodName, $returnType) {
|
||||||
|
|
||||||
|
try {
|
||||||
$instance = $container->invoker->invoke(ClassName::create($className), $methodName);
|
$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
|
// Wenn das ein Interface ist, registriere auch die konkrete Klasse automatisch
|
||||||
if (interface_exists($returnType)) {
|
if (interface_exists($returnType)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user