ScopeNotActiveException class

The error thrown when a bean is looked up while its scope is not active, for example a screen-scoped bean while no screen is open.

The CustomScope signals this by throwing a StateError from get. A singleton that needs such a bean should get it through a scoped proxy or an ObjectProvider, whose getIfAvailable, getIfUnique and ifAvailable treat an inactive scope like a missing bean. It is a BeanCreationException.

// A scope that is only active while a screen is open.
class ScreenScope implements CustomScope {
  @override
  Object get(String name, Object Function() objectFactory) =>
      _current?.get(name, objectFactory) ??
      (throw StateError('No screen is open'));
  ...
}
cartProvider.getIfAvailable(); // null while no screen is open

Spring (Java):

cartProvider.getIfAvailable(); // null outside the scope
Inheritance

Constructors

ScopeNotActiveException(String beanName, String scopeName, Object cause, [StackTrace? causeStackTrace])
The bean beanName of scope scopeName cannot be reached now; cause is the scope's StateError.

Properties

beanName → String
The bean whose creation failed.
finalinherited
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).
finalinherited
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
scopeName → String
The inactive scope.
final

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