-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] Adding in handling for secondary rate limit exceptions (#2473)
- Loading branch information
1 parent
6f78c52
commit b023602
Showing
3 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
#if !NO_SERIALIZABLE | ||
using System.Runtime.Serialization; | ||
#endif | ||
|
||
namespace Octokit | ||
{ | ||
/// <summary> | ||
/// Exception thrown when Secondary GitHub API Rate limits are exceeded. | ||
/// </summary> | ||
/// <summary> | ||
/// <para> | ||
/// This occurs when GitHub perceives misuse of the API. You may get this if | ||
/// you are polling heavily, creating content rapidly or making concurrent requests. | ||
/// </para> | ||
/// <para>See https://docs.github.com/en/rest/overview/resources-in-the-rest-api#secondary-rate-limits for more details.</para> | ||
/// </summary> | ||
#if !NO_SERIALIZABLE | ||
[Serializable] | ||
#endif | ||
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", | ||
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] | ||
public class SecondaryRateLimitExceededException : ForbiddenException | ||
{ | ||
/// <summary> | ||
/// Constructs an instance of the <see cref="Octokit.SecondaryRateLimitExceededException"/> class. | ||
/// </summary> | ||
/// <param name="response">The HTTP payload from the server</param> | ||
public SecondaryRateLimitExceededException(IResponse response) : this(response, null) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Constructs an instance of the <see cref="Octokit.SecondaryRateLimitExceededException"/> class. | ||
/// </summary> | ||
/// <param name="response">The HTTP payload from the server</param> | ||
/// <param name="innerException">The inner exception</param> | ||
public SecondaryRateLimitExceededException(IResponse response, Exception innerException) : base(response, innerException) | ||
{ | ||
Ensure.ArgumentNotNull(response, nameof(response)); | ||
} | ||
|
||
public override string Message | ||
{ | ||
get { return ApiErrorMessageSafe ?? "Secondary API Rate Limit exceeded"; } | ||
} | ||
|
||
#if !NO_SERIALIZABLE | ||
/// <summary> | ||
/// Constructs an instance of <see cref="Octokit.SecondaryRateLimitExceededException"/>. | ||
/// </summary> | ||
/// <param name="info"> | ||
/// The <see cref="SerializationInfo"/> that holds the | ||
/// serialized object data about the exception being thrown. | ||
/// </param> | ||
/// <param name="context"> | ||
/// The <see cref="StreamingContext"/> that contains | ||
/// contextual information about the source or destination. | ||
/// </param> | ||
protected SecondaryRateLimitExceededException(SerializationInfo info, StreamingContext context) | ||
: base(info, context) | ||
{ | ||
} | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters