You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
883 B
33 lines
883 B
using System.Net;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Http;
|
|
using NzbDrone.Common.Serializer;
|
|
using Prowlarr.Http.Exceptions;
|
|
|
|
namespace Prowlarr.Http.ErrorManagement
|
|
{
|
|
public class ErrorModel
|
|
{
|
|
public string Message { get; set; }
|
|
public string Description { get; set; }
|
|
public object Content { get; set; }
|
|
|
|
public ErrorModel(ApiException exception)
|
|
{
|
|
Message = exception.Message;
|
|
Content = exception.Content;
|
|
}
|
|
|
|
public ErrorModel()
|
|
{
|
|
}
|
|
|
|
public Task WriteToResponse(HttpResponse response, HttpStatusCode statusCode = HttpStatusCode.InternalServerError)
|
|
{
|
|
response.StatusCode = (int)statusCode;
|
|
response.ContentType = "application/json";
|
|
return STJson.SerializeAsync(this, response.Body);
|
|
}
|
|
}
|
|
}
|