ApiError class

Normalised API error. Carried by Failure<T> in the Result type.

Properties: message — human-readable summary. type — machine-readable category for UI routing. statusCode — HTTP status code, if applicable. cause — the original exception, for debugging. rawBody — unparsed response body, useful for logging. requestId — optional server-side correlation ID (from response headers).

Implemented types

Constructors

ApiError({required String message, required ApiErrorType type, int? statusCode, Object? cause, String? rawBody, String? requestId, DateTime? timestamp})
ApiError.cancelled()
Creates a cancellation error.
factory
ApiError.fromStatus(int code, {String? body, String? requestId})
Creates an ApiError from an HTTP status code.
factory
ApiError.network(Object cause)
Creates a network-level error (no internet, DNS failure, etc.).
factory
ApiError.parseError(Object cause, {String? rawBody})
Creates a JSON parse error.
factory
ApiError.timeout({Duration? duration})
Creates a timeout error.
factory

Properties

cause Object?
final
hashCode int
The hash code for this object.
no setterinherited
isCancelled bool
no setter
isNetworkError bool
no setter
isNotFound bool
no setter
isRateLimited bool
no setter
isRetryable bool
Returns true if this error is recoverable by retrying the request.
no setter
isServerError bool
no setter
isTimeout bool
no setter
isUnauthorized bool
no setter
message String
final
rawBody String?
final
requestId String?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int?
final
timestamp DateTime
final
type ApiErrorType
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

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