mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
started to remove iisexpress.
This commit is contained in:
parent
40f3a8663d
commit
68128809c9
39 changed files with 383 additions and 820 deletions
41
NzbDrone.Api/ErrorManagement/ApiException.cs
Normal file
41
NzbDrone.Api/ErrorManagement/ApiException.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Nancy;
|
||||
using Nancy.Responses;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Api.Extentions;
|
||||
|
||||
namespace NzbDrone.Api.ErrorManagement
|
||||
{
|
||||
public abstract class ApiException : Exception
|
||||
{
|
||||
public object Content { get; private set; }
|
||||
|
||||
|
||||
public HttpStatusCode StatusCode { get; private set; }
|
||||
|
||||
protected ApiException(HttpStatusCode statusCode, object content = null)
|
||||
: base(GetMessage(statusCode, content))
|
||||
{
|
||||
StatusCode = statusCode;
|
||||
Content = content;
|
||||
}
|
||||
|
||||
public JsonResponse<ErrorModel> ToErrorResponse()
|
||||
{
|
||||
return new ErrorModel(this).AsResponse(StatusCode);
|
||||
}
|
||||
|
||||
private static string GetMessage(HttpStatusCode statusCode, object content)
|
||||
{
|
||||
var result = statusCode.ToString();
|
||||
|
||||
if (content != null)
|
||||
{
|
||||
result = result + " :" + JsonConvert.SerializeObject(content);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue