mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
Added NMA support, also added generic HttpStatusCode handling
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace NzbDrone.Core.Exceptions
|
||||
{
|
||||
public class BadRequestException : DownstreamException
|
||||
{
|
||||
public BadRequestException(HttpStatusCode statusCode, string message) : base(statusCode, message)
|
||||
{
|
||||
}
|
||||
|
||||
public BadRequestException(HttpStatusCode statusCode, string message, params object[] args) : base(statusCode, message, args)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Net;
|
||||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace NzbDrone.Core.Exceptions
|
||||
{
|
||||
public class DownstreamException : NzbDroneException
|
||||
{
|
||||
public HttpStatusCode StatusCode { get; private set; }
|
||||
|
||||
public DownstreamException(HttpStatusCode statusCode, string message, params object[] args) : base(message, args)
|
||||
{
|
||||
StatusCode = statusCode;
|
||||
}
|
||||
|
||||
public DownstreamException(HttpStatusCode statusCode, string message)
|
||||
: base(message)
|
||||
{
|
||||
StatusCode = statusCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Net;
|
||||
using NzbDrone.Common.Exceptions;
|
||||
|
||||
namespace NzbDrone.Core.Exceptions
|
||||
{
|
||||
public class NzbDroneClientException : NzbDroneException
|
||||
{
|
||||
public HttpStatusCode StatusCode { get; private set; }
|
||||
|
||||
public NzbDroneClientException(HttpStatusCode statusCode, string message, params object[] args) : base(message, args)
|
||||
{
|
||||
StatusCode = statusCode;
|
||||
}
|
||||
|
||||
public NzbDroneClientException(HttpStatusCode statusCode, string message)
|
||||
: base(message)
|
||||
{
|
||||
StatusCode = statusCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user