You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
933 B
32 lines
933 B
using System;
|
|
using System.Net;
|
|
|
|
namespace NzbDrone.Core.Exceptions
|
|
{
|
|
public static class StatusCodeToExceptions
|
|
{
|
|
public static void VerifyStatusCode(this HttpStatusCode statusCode, string message = null)
|
|
{
|
|
if (String.IsNullOrEmpty(message))
|
|
{
|
|
message = statusCode.ToString();
|
|
}
|
|
|
|
switch (statusCode)
|
|
{
|
|
case HttpStatusCode.BadRequest:
|
|
throw new BadRequestException(statusCode, message);
|
|
|
|
case HttpStatusCode.Unauthorized:
|
|
throw new UnauthorizedAccessException(message);
|
|
|
|
case HttpStatusCode.PaymentRequired:
|
|
throw new DownstreamException(statusCode, message);
|
|
|
|
case HttpStatusCode.InternalServerError:
|
|
throw new DownstreamException(statusCode, message);
|
|
}
|
|
}
|
|
}
|
|
}
|