mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 03:30:34 +00:00
[FEAT] Adding in handling for secondary rate limit exceptions (#2473)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user