AppExceptionMappingInterceptor class

Dio interceptor that maps low-level network errors to application exceptions.

Transforms DioException instances into domain-specific AppException subclasses, providing a consistent exception hierarchy throughout the app. This allows business logic to handle errors without depending on Dio-specific types.

The interceptor analyzes both the Dio error type and HTTP status codes to determine the appropriate exception type. It also extracts error messages from response bodies when available.

Error mapping strategy:

Must be positioned before ReportingInterceptor and AuthFailureInterceptor in the Dio interceptor chain so those interceptors receive typed AppException values on DioException.error rather than raw Dio error objects.

See also:

Inheritance

Constructors

AppExceptionMappingInterceptor({required AppLogger logger})
Creates a mapping interceptor that uses logger to warn on unmapped HTTP status codes.

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onError(DioException err, ErrorInterceptorHandler handler) → void
Intercepts Dio errors and replaces them with typed app exceptions.
override
onRequest(RequestOptions options, RequestInterceptorHandler handler) → void
Called when the request is about to be sent.
inherited
onResponse(Response response, ResponseInterceptorHandler handler) → void
Called when the response is about to be resolved.
inherited
toString() String
A string representation of this object.
inherited

Operators

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