using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; using System.Runtime.Serialization; namespace Octokit { /// /// Represents a HTTP 403 - Forbidden response returned from the API. /// [Serializable] [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class ForbiddenException : ApiException { /// /// Constructs an instance of ForbiddenException /// /// The HTTP payload from the server public ForbiddenException(IResponse response) : this(response, null) { } /// /// Constructs an instance of ForbiddenException /// /// The HTTP payload from the server /// The inner exception 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"; } } /// /// Constructs an instance of ForbiddenException /// /// /// The that holds the /// serialized object data about the exception being thrown. /// /// /// The that contains /// contextual information about the source or destination. /// protected ForbiddenException(SerializationInfo info, StreamingContext context) : base(info, context) { } } }