tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
RateLimitException.cs
Go to the documentation of this file.
1using System;
2using System.Linq;
3using System.Net.Http;
4
5using Microsoft.Net.Http.Headers;
6
8
10{
14 public sealed class RateLimitException : ApiException
15 {
19 public DateTimeOffset? RetryAfter { get; }
20
26 public RateLimitException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage)
27 : base(errorMessage, responseMessage)
28 {
29 if (responseMessage == null)
30 throw new ArgumentNullException(nameof(responseMessage));
31
32 if (!responseMessage.Headers.TryGetValues(HeaderNames.RetryAfter, out var values))
33 return;
34
35 var secondsString = values.FirstOrDefault();
36 if (UInt32.TryParse(secondsString, out var seconds))
37 RetryAfter = DateTimeOffset.UtcNow.AddSeconds(seconds);
38 }
39
44 {
45 }
46
51 public RateLimitException(string message)
52 : base(message)
53 {
54 }
55
61 public RateLimitException(string message, Exception innerException)
62 : base(message, innerException)
63 {
64 }
65 }
66}
Represents an error message returned by the server.
Occurs when a GitHub rate limit occurs.
RateLimitException()
Initializes a new instance of the RateLimitException class.
DateTimeOffset? RetryAfter
Gets the DateTimeOffset to try the request again after.
RateLimitException(string message)
Initializes a new instance of the RateLimitException class.
RateLimitException(string message, Exception innerException)
Initializes a new instance of the RateLimitException class.
RateLimitException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage)
Initializes a new instance of the RateLimitException class.