blob: da1e04ce425f87d32250f58481d21954e82e3a66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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; }
}
|