Errors
This page describes errors and custom exceptions raised by Rodi.
Errors¶
Name | Description |
---|---|
CannotResolveTypeException |
This error is raised when a type cannot be resolved because it was not registered in the container. |
CircularDependencyException |
This error is raised when a circular dependency is detected and cannot be resolved. |
FactoryMissingContextException |
This error is raised when a factory function does not have _locals . This generally happens only if classes are defined inside functions and use locals (not a common case). |
MissingTypeException |
This error is raised when a factory function does not specify its return type annotation, and the user does not specify the type it returns. |
OverridingServiceException |
This error is raised when the user tries to override a type that is already registered in the container. |
Cannot resolve type¶
rodi.CannotResolveParameterException: Unable to resolve parameter 'dependency' when resolving 'B'
All dependencies must be explicitly registered in the container. To resolve the error, register the missing type:
The chicken and egg problem
¶
The following classes have a circular dependency:
If we try to have Rodi resolve them automatically, we get an error:
The raised error is:
raise CircularDependencyException(chain[0], concrete_type)
rodi.CircularDependencyException: A circular dependency was detected for the service of type 'Chicken' for 'Egg'
.
Rodi cannot infer automatically which type should be instantiated first: Chicken or Egg?
Last modified on: 2025-04-17 07:04:37
RP