fix(InitializerProcessor): Add error logging to registerLazyService method

- Add error logging for lazy service registration failures
- Log return_type, class, method, and full exception details
- Helps diagnose why DatabasePlatform initializer registration fails silently
This commit is contained in:
2025-10-27 10:17:15 +01:00
parent ddeca45a78
commit 7b77b580d3

View File

@@ -186,7 +186,19 @@ final readonly class InitializerProcessor
$this->container->singleton($returnType, $factory);
} catch (\Throwable $e) {
// Service registration failed - continue
// Safe Logger resolution - use if available
$logger = $this->container->has(Logger::class) ? $this->container->get(Logger::class) : null;
$logger?->error(
"Failed to register lazy service for return type: {$returnType}",
LogContext::withExceptionAndData($e, [
'return_type' => $returnType,
'class' => $className,
'method' => $methodName,
])
);
// Service registration failed - continue to prevent breaking the entire application
}
}
}