using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Net; using System.Runtime.Serialization; namespace Octokit { /// /// Represents a HTTP 451 - Unavailable For Legal Reasons response returned from the API. /// This will returned if GitHub has been asked to takedown the requested resource due to /// a DMCA takedown. /// #if !NETFX_CORE [Serializable] #endif [SuppressMessage("Microsoft.Design", "CA1032:ImplementStandardExceptionConstructors", Justification = "These exceptions are specific to the GitHub API and not general purpose exceptions")] public class LegalRestrictionException : ApiException { public override string Message { get { return ApiErrorMessageSafe ?? "Resource taken down due to a DMCA notice."; } } /// /// Constructs an instance of LegalRestrictionException /// /// The HTTP payload from the server public LegalRestrictionException(IResponse response) : this(response, null) { } /// /// Constructs an instance of LegalRestrictionException /// /// The exception message /// The http status code returned by the response public LegalRestrictionException(string message, HttpStatusCode statusCode) : base(message, statusCode) { } /// /// Constructs an instance of LegalRestrictionException /// /// The HTTP payload from the server /// The inner exception public LegalRestrictionException(IResponse response, Exception innerException) : base(response, innerException) { Debug.Assert(response != null && response.StatusCode == (HttpStatusCode)451, "LegalRestrictionException created with wrong status code"); } #if !NETFX_CORE /// /// Constructs an instance of LegalRestrictionException /// /// /// The that holds the /// serialized object data about the exception being thrown. /// /// /// The that contains /// contextual information about the source or destination. /// protected LegalRestrictionException(SerializationInfo info, StreamingContext context) : base(info, context) { } #endif } }