fix(InitializerProcessor): Add error logging for failed initializer registration
- Add LogContext import for structured error logging - Replace silent exception catching with detailed error logging - Log class, method, return_type, and full exception details - Helps diagnose DatabasePlatform initializer issues in production - Maintains application stability by skipping failed initializers
This commit is contained in:
@@ -14,6 +14,7 @@ use App\Framework\DI\InitializerDependencyGraph;
|
||||
use App\Framework\DI\ValueObjects\DependencyGraphNode;
|
||||
use App\Framework\Discovery\Results\DiscoveryRegistry;
|
||||
use App\Framework\Logging\Logger;
|
||||
use App\Framework\Logging\ValueObjects\LogContext;
|
||||
use App\Framework\Reflection\ReflectionProvider;
|
||||
|
||||
/**
|
||||
@@ -81,9 +82,16 @@ final readonly class InitializerProcessor
|
||||
$dependencyGraph->addInitializer($returnType, $discoveredAttribute->className, $methodName);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$logger?->error(
|
||||
"Failed to register initializer: {$discoveredAttribute->className->toString()}::{$methodName->toString()}",
|
||||
LogContext::withExceptionAndData($e, [
|
||||
'class' => $discoveredAttribute->className->toString(),
|
||||
'method' => $methodName->toString(),
|
||||
'return_type' => $returnType,
|
||||
])
|
||||
);
|
||||
|
||||
|
||||
// Skip failed initializers
|
||||
// Skip failed initializers to prevent breaking the entire application
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user