ExceptionResolverManager class final

Central registry and lifecycle coordinator for all ExceptionResolver instances in the Jetleaf web framework.

The ExceptionResolverManager is responsible for discovering, ordering, and managing all exception resolvers that handle errors during the HTTP request–response lifecycle.
Each ExceptionResolver knows how to process a specific type of exception and convert it into an appropriate HttpResponse.

Responsibilities

  • Scans the ApplicationContext for registered ExceptionResolver Pods.
  • Allows WebConfigurer implementations to contribute custom resolvers.
  • Maintains a globally ordered chain of resolvers for exception handling.
  • Ensures deterministic and predictable resolution order.

Initialization Flow

  1. During application startup, onReady is invoked automatically.
  2. The manager queries the ApplicationContext for all ExceptionResolver Pods.
  3. Custom resolvers are added via WebConfigurer.addExceptionResolvers.
  4. Resolvers are ordered using AnnotationAwareOrderComparator.

Exception Handling Strategy

When an exception is thrown during request processing:

  1. The dispatcher retrieves the ordered list of resolvers.
  2. Each resolver is invoked sequentially until one successfully handles the exception.
  3. The first resolver that returns true short-circuits further processing.
  4. If no resolver handles the exception, the framework’s fallback error handler is used.

Example

final manager = ExceptionResolverManager();
manager.setApplicationContext(context);
await manager.onReady();

final resolvers = manager.getExceptionResolvers();
for (final resolver in resolvers) {
  print('Loaded resolver: ${resolver.runtimeType}');
}

Common Resolver Types

  • ControllerAdviceExceptionResolver — Handles exceptions from annotated controllers
  • ResponseStatusExceptionResolver — Maps exceptions to HTTP statuses
  • DefaultExceptionResolver — Provides default framework error handling
  • CustomBusinessExceptionResolver — Handles domain-specific exceptions

See also

Constructors

ExceptionResolverManager(ContentNegotiationResolver _negotiationResolver)
Central registry and lifecycle coordinator for all ExceptionResolver instances in the Jetleaf web framework.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

getPackageName() → String
Represents an abstraction for identifying the package that an object, resource, or service belongs to.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onReady() → Future<void>
Interface to be implemented by pods that require initialization logic after their properties have been set by the container.
resolve(ServerHttpRequest request, ServerHttpResponse response, HandlerMethod? method, Object ex, StackTrace st) → Future<bool>
Attempts to resolve an exception using the configured exception resolvers.
setApplicationContext(ApplicationContext applicationContext) → void
Sets the ApplicationContext that this component runs in.
toString() → String
A string representation of this object.
inherited

Operators

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