TooManyRequestsException class
Exception for HTTP 429 Too Many Requests errors.
Thrown when the client has exceeded a rate limit — e.g. requesting an OTP
or password-reset email too frequently. retryAfter, when present, comes
from the response's Retry-After header and indicates how long to wait
before retrying.
Example:
if (response.statusCode == 429) {
throw TooManyRequestsException(
retryAfter: Duration(seconds: int.tryParse(response.headers.value('retry-after') ?? '') ?? 0),
originalException: dioError,
);
}
- Inheritance
-
- Object
- AppException
- NetworkAppException
- TooManyRequestsException
Constructors
- TooManyRequestsException({String? message, Duration? retryAfter, DioException? originalException, String? errorCode, String? traceId})
-
Creates a TooManyRequestsException with an optional custom
messageandretryAfter.const
Properties
- errorCode → String?
-
A machine-readable error code from the backend's
ErrorResponseenvelope (e.g.VALIDATION_ERROR,TOO_MANY_REQUESTS), ornullif the response body didn't match that schema.finalinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- message → String
-
A human-readable description of the error.
finalinherited
- originalException → DioException?
-
The underlying Dio exception that caused this network error.
finalinherited
- retryAfter → Duration?
-
How long to wait before retrying, parsed from the
Retry-Afterresponse header —nullif the header was absent or unparsable.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- traceId → String?
-
The backend's request-trace identifier from the
ErrorResponseenvelope, for correlating this error with server-side logs — ornullif the response body didn't match that schema.finalinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
The string representation of this exception, including Dio-level details.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited