BeanCreationException class

The error thrown when creating a bean failed: its constructor or @Bean method, its injection or an init callback threw.

beanName is the bean being created and cause what went wrong. Errors of nested beans are wrapped once per level, so the chain of causes leads to the bean that actually failed; rootCause is the original error.

// Log which bean failed and why.
try {
  factory.getBean<Mailer>();
} on BeanCreationException catch (e) {
  log.error(e.beanName, error: e.cause, stackTrace: e.causeStackTrace);
}

Spring (Java):

try {
  factory.getBean(Mailer.class);
} catch (BeanCreationException e) {
  log.error(e.getBeanName(), e.getMostSpecificCause());
}
Inheritance

Constructors

BeanCreationException(String beanName, Object cause, StackTrace causeStackTrace)
Creating beanName failed with cause, thrown at causeStackTrace.
BeanCreationException.withMessage(String beanName, String message, {Object? cause, StackTrace? causeStackTrace})
Creating beanName failed as message describes; used by the subclasses.

Properties

beanName → String
The bean whose creation failed.
final
cause → Object?
The error that caused this one, if any: what a constructor threw, or the container error of a nested bean.
finalinherited
causeStackTrace → StackTrace
The stack trace of cause (empty without a cause).
final
hashCode → int
The hash code for this object.
no setterinherited
message → String
A human-readable description of the problem.
finalinherited
mostSpecificCause → Object
rootCause, or this exception when it has no cause. Spring: getMostSpecificCause().
no setterinherited
rootCause → Object?
The innermost cause: cause followed through nested container errors, or null without a cause. Usually the error that really went wrong. Spring: getRootCause().
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited