TooManyRequestsException class

Exception thrown when the rate limit for requests to the Horizon server is exceeded.

Horizon enforces rate limits to prevent abuse. When the limit is exceeded, this exception is thrown with a suggested retry-after delay in seconds.

Parameters:

  • retryAfter: Number of seconds to wait before retrying the request

Example:

try {
  var accounts = await sdk.accounts.forSigner(signerKey).execute();
} catch (e) {
  if (e is TooManyRequestsException) {
    print('Rate limited. Retry after: ${e.retryAfter} seconds');
    await Future.delayed(Duration(seconds: e.retryAfter ?? 60));
    // Retry the request
  }
}

See also:

Implemented types

Constructors

TooManyRequestsException(int? _retryAfter)
Creates a rate limit exception with an optional retry-after delay in seconds.

Properties

hashCode int
The hash code for this object.
no setterinherited
retryAfter int?
no setter
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
toString() String
Returns a string representation of this instance for debugging.
override

Operators

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