1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2025-02-14 18:45:33 +00:00
Radarr/NzbDrone.Core/Exceptions/StatusCodeToExceptions.cs

34 lines
1,005 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
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);
}
}
}
}