diff options
| author | Murilo Ijanc <[email protected]> | 2026-07-26 12:42:38 -0300 |
|---|---|---|
| committer | Murilo Ijanc <[email protected]> | 2026-07-26 13:10:34 -0300 |
| commit | a2b10fd494fb389e556e40134031eb86e56e11e7 (patch) | |
| tree | 08b6df8a06f2c7c15488b90d57a6d8286cd57a22 /src/Cepis/RateLimitedException.cs | |
| download | csharp-a2b10fd494fb389e556e40134031eb86e56e11e7.tar.gz | |
Initial importv0.1.0
Diffstat (limited to 'src/Cepis/RateLimitedException.cs')
| -rw-r--r-- | src/Cepis/RateLimitedException.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/Cepis/RateLimitedException.cs b/src/Cepis/RateLimitedException.cs new file mode 100644 index 0000000..da1e04c --- /dev/null +++ b/src/Cepis/RateLimitedException.cs @@ -0,0 +1,39 @@ +namespace Cepis; + +/// <summary> +/// The API, or the edge in front of it, answered 429 on every attempt. +/// </summary> +public sealed class RateLimitedException : CepisException +{ + /// <summary>Create the exception with a message and the wait requested.</summary> + /// <param name="message">what went wrong</param> + /// <param name="retryAfter"> + /// what the server asked for, or <see langword="null"/> if it did not say + /// </param> + public RateLimitedException(string message, TimeSpan? retryAfter = null) + : base(message) + { + RetryAfter = retryAfter; + } + + /// <summary>Create the exception with a message, the wait and a cause.</summary> + /// <param name="message">what went wrong</param> + /// <param name="retryAfter">what the server asked for, if anything</param> + /// <param name="innerException">the failure underneath</param> + public RateLimitedException(string message, TimeSpan? retryAfter, Exception? innerException) + : base(message, innerException) + { + RetryAfter = retryAfter; + } + + /// <summary> + /// How long the server asked the caller to wait, or <see langword="null"/> + /// if it did not say. + /// </summary> + /// <remarks> + /// The client already honoured this across the attempts it made, capped at + /// <see cref="CepisClientOptions.BackoffMax"/>. It is exposed here for + /// callers who want to reschedule the work. + /// </remarks> + public TimeSpan? RetryAfter { get; } +} |