ExceptionHandler class
Middleware that catches exceptions and returns appropriate error responses.
- HttpException: Returns the exception's status code and message
- Other exceptions: Returns 500 Internal Server Error (details logged but not exposed)
Example:
final app = Chase()
..use(RequestId()) // Add request ID first
..use(ExceptionHandler()) // Then exception handler
..get('/').handle((ctx) {
throw HttpException.notFound('Resource not found');
});
- Implemented types
Constructors
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
-
handle(
Context ctx, NextFunction next) → FutureOr< void> -
override
-
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