1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-01-31 11:53:06 +00:00
Radarr/NzbDrone.Core/Exceptions/StatusCodeToExceptions.cs
2013-09-25 19:51:07 -07:00

31 lines
921 B
C#

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(message);
case HttpStatusCode.Unauthorized:
throw new UnauthorizedAccessException(message);
case HttpStatusCode.PaymentRequired:
throw new DownstreamException(statusCode, message);
case HttpStatusCode.InternalServerError:
throw new DownstreamException(statusCode, message);
}
}
}
}