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.
50 lines
1.3 KiB
50 lines
1.3 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace NzbDrone.Core.ImportLists.RadarrList
|
|
{
|
|
public class RadarrListException : Exception
|
|
{
|
|
public RadarrErrors APIErrors;
|
|
|
|
public RadarrListException(RadarrErrors apiError)
|
|
: base(HumanReadable(apiError))
|
|
{
|
|
APIErrors = apiError;
|
|
}
|
|
|
|
private static string HumanReadable(RadarrErrors apiErrors)
|
|
{
|
|
var firstError = apiErrors.Errors.First();
|
|
var details = string.Join("\n", apiErrors.Errors.Select(error =>
|
|
{
|
|
return $"{error.Title} ({error.Status}, RayId: {error.RayId}), Details: {error.Detail}";
|
|
}));
|
|
return $"Error while calling api: {firstError.Title}\nFull error(s): {details}";
|
|
}
|
|
}
|
|
|
|
public class RadarrError
|
|
{
|
|
[JsonProperty("id")]
|
|
public string RayId { get; set; }
|
|
|
|
[JsonProperty("status")]
|
|
public int Status { get; set; }
|
|
|
|
[JsonProperty("title")]
|
|
public string Title { get; set; }
|
|
|
|
[JsonProperty("detail")]
|
|
public string Detail { get; set; }
|
|
}
|
|
|
|
public class RadarrErrors
|
|
{
|
|
[JsonProperty("errors")]
|
|
public IList<RadarrError> Errors { get; set; }
|
|
}
|
|
}
|