Class RateLimitError
- Namespace
- Trellis
- Assembly
- Trellis.Results.dll
Represents a rate limiting error when too many requests have been made. Use this when a client has exceeded their request quota or rate limit. Maps to HTTP 429 Too Many Requests.
public sealed class RateLimitError : Error, IEquatable<Error>
- Inheritance
-
RateLimitError
- Implements
- Inherited Members
- Extension Methods
Examples
Error.RateLimit("API rate limit exceeded. Please try again in 60 seconds")
Error.RateLimit("Daily quota of 1000 requests exceeded", userId)
Error.RateLimit("Too many login attempts. Account temporarily locked")
Remarks
Include retry-after information in the detail message when appropriate. Consider adding custom properties for RetryAfter seconds if needed for your API design.
Constructors
RateLimitError(string, string, string?)
Initializes a new instance of the RateLimitError class.
public RateLimitError(string detail, string code, string? instance = null)
Parameters
detailstringDescription of the rate limit violation.
codestringThe error code identifying this type of rate limit error.
instancestringOptional identifier for the client or resource being rate limited.
RateLimitError(string, string, RetryAfterValue, string?)
Initializes a new instance of the RateLimitError class with retry-after metadata.
public RateLimitError(string detail, string code, RetryAfterValue retryAfter, string? instance = null)
Parameters
detailstringDescription of the rate limit violation.
codestringThe error code identifying this type of rate limit error.
retryAfterRetryAfterValueThe retry-after value indicating when the client may retry.
instancestringOptional identifier for the client or resource being rate limited.
Properties
RetryAfter
Gets the optional retry-after value indicating when the rate limit resets.
When present, Trellis response mappers emit the Retry-After header.
public RetryAfterValue? RetryAfter { get; }