mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-30 03:38:26 -07:00
Added NMA support, also added generic HttpStatusCode handling
This commit is contained in:
parent
de012aec21
commit
eb7dda0629
12 changed files with 254 additions and 2 deletions
34
NzbDrone.Core/Exceptions/StatusCodeToExceptions.cs
Normal file
34
NzbDrone.Core/Exceptions/StatusCodeToExceptions.cs
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue