ExceptionHandler class

Handles exceptions raised in the application and returns standardized error results.

This class provides comprehensive exception handling with:

  • Automatic RFC 7807 Problem Details mapping
  • Request context inclusion in error reports (if available)
  • Development vs production error detail levels
  • Custom error mapping

The handler is protocol-agnostic and returns an ErrorResult which can be formatted by the transport layer (HTTP, Socket, etc.).

Implemented types

Constructors

ExceptionHandler()

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

configure({bool showDetailedErrors = true, bool includeStackTracesInResponse = false}) → void
Configure exception handling settings
handle(Object error, [StackTrace? stackTrace]) Future<ErrorResult>
Handle an exception and return a standardized error result.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
register<T extends Object>(Future<ErrorResult> handler(T error, StackTrace? stackTrace)) → void
Register a custom handler for a specific exception type.
override
toString() String
A string representation of this object.
inherited

Operators

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