using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Net;
using System.Runtime.Serialization;
using Octokit.Internal;
namespace Octokit
{
///
/// Represents a HTTP 401 - Unauthorized response returned from the API.
///
#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 AuthorizationException : ApiException
{
///
/// Constructs an instance of AuthorizationException
///
public AuthorizationException() : base(new Response { StatusCode = HttpStatusCode.Unauthorized })
{
}
///
/// Constructs an instance of AuthorizationException
///
/// The HTTP payload from the server
public AuthorizationException(IResponse response)
: this(response, null)
{
}
///
/// Constructs an instance of AuthorizationException
///
/// The HTTP payload from the server
/// The inner exception
public AuthorizationException(IResponse response, Exception innerException)
: base(response, innerException)
{
Debug.Assert(response != null && response.StatusCode == HttpStatusCode.Unauthorized,
"AuthorizationException created with wrong status code");
}
#if !NETFX_CORE
///
/// Constructs an instance of AuthorizationException.
///
///
/// The that holds the
/// serialized object data about the exception being thrown.
///
///
/// The that contains
/// contextual information about the source or destination.
///
protected AuthorizationException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
#endif
}
}