You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
4.0: runtime scope errors should be ResolutionErrors #562
This was generated by AI during a pre-4.0 audit of main at 9cd88e7.
Observation
docs/providers/errors-and-exceptions.md:101 says "Catch ResolutionError for any resolution failure", but ScopeNotInitializedError, ScopeSkippedError and ContainerClosedError subclass ContainerError (modern_di/exceptions/container.py:50,69,102). So except ResolutionError misses root.resolve(RequestScoped) and a resolve from a closed container.
Related: InvalidScopeDependencyError (exceptions/registration.py:168) subclasses RegistrationError, a module documented as "while providers and groups are declared", but it is raised by validate() (dependency_graph.py:197), so except RegistrationError catches a validation finding.
Changing a base class after 4.0 changes which except clauses fire, so it is a 5.0 change later and cheap now.
Proposal
Re-parent the three runtime errors under ResolutionError (they already carry DependencyPathMixin). Decide whether ContainerError stays a second base for them or is reserved for construction-time errors (InvalidChildScopeError, MaxScopeReachedError, InvalidScopeTypeError).
Decide the family of InvalidScopeDependencyError (validation, not registration).
Update errors-and-exceptions.md and the migration guide.
Acceptance
except ResolutionError catches every error raised from resolve/resolve_provider, with a test per error type.
Hierarchy table in the docs matches the code; migration guide has an entry.
Activity
feat!: scope errors are ResolutionErrors (#581)