Skip to content

Exceptions ​

All exceptions are unchecked and share a common root, DiException (extends RuntimeException). You can catch DiException to handle any container error, or a specific subtype for finer control.

Hierarchy ​

text
DiException
├── BeanResolutionException        // resolving or creating a bean failed
│   ├── NoSuchBeanException        // no provider available
│   ├── AmbiguousBeanException     // several providers for a single-value resolution
│   ├── UnsupportedInjectionException  // type not injectable / unsupported generic
│   └── BeanCreationException      // reflective instantiation failed
├── InitializationException        // misuse of a ScopeInitialization session
└── ScopeException                 // scope-graph / lifecycle error
    ├── ScopeCycleException        // attaching a parent would create a cycle
    ├── ScopeConflictException     // ownership conflict with an open child
    └── ScopeStateException        // operation on a closing/closed scope

Resolution and creation ​

ExceptionThrown when
BeanResolutionExceptionBase for resolution/creation failures.
NoSuchBeanExceptionget/provider finds no provider and cannot create one.
AmbiguousBeanExceptionA single-value lookup matches more than one nearest provider. Qualify, shadow, or use providers(...).
UnsupportedInjectionExceptionA type cannot be injected — e.g. no single public constructor, a non-concrete generic, a local/anonymous/non-static inner class.
BeanCreationExceptionThe constructor or a @PostConstruct threw during instantiation. The bean is not exposed as a scope singleton.

Initialization ​

ExceptionThrown when
InitializationExceptionA ScopeInitialization session is misused — committing twice, or registering an event after the session ended.

Scopes ​

ExceptionThrown when
ScopeExceptionBase for scope errors. Also raised by close() (with the individual failures attached as suppressed exceptions) when cleanups fail.
ScopeCycleExceptionAn attach / ownedBy / weakRef would make the graph cyclic.
ScopeConflictExceptionAttaching a second open owned child under the same context, or detachWeakRef with no matching weak reference.
ScopeStateExceptionAny operation on a scope that is CLOSING or CLOSED.

See also: Injection (what makes a type injectable), Multi-parent scopes (ambiguity), and Scopes & lifecycle (close semantics).