Files
octokit.net/Octokit/Exceptions/ForbiddenException.cs
2022-08-12 12:19:26 -05:00

59 lines
2.1 KiB
C#

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Runtime.Serialization;
namespace Octokit
{
/// <summary>
/// Represents a HTTP 403 - Forbidden response returned from the API.
/// </summary>
[Serializable]
[SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors",
Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")]
public class ForbiddenException : ApiException
{
/// <summary>
/// Constructs an instance of ForbiddenException
/// </summary>
/// <param name="response">The HTTP payload from the server</param>
public ForbiddenException(IResponse response) : this(response, null)
{
}
/// <summary>
/// Constructs an instance of ForbiddenException
/// </summary>
/// <param name="response">The HTTP payload from the server</param>
/// <param name="innerException">The inner exception</param>
public ForbiddenException(IResponse response, Exception innerException)
: base(response, innerException)
{
Debug.Assert(response != null && response.StatusCode == HttpStatusCode.Forbidden,
"ForbiddenException created with wrong status code");
}
public override string Message
{
get { return ApiErrorMessageSafe ?? "Request Forbidden"; }
}
/// <summary>
/// Constructs an instance of ForbiddenException
/// </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 ForbiddenException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}