mirror of
https://github.com/Prowlarr/Prowlarr
synced 2025-12-06 08:34:28 +01:00
Improve error messaging for not finding JSON selectors in Cardigann
This commit is contained in:
parent
0b3a5c9bc4
commit
48a658571b
2 changed files with 8 additions and 7 deletions
|
|
@ -8,6 +8,7 @@
|
|||
using System.Text.RegularExpressions;
|
||||
using AngleSharp.Dom;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
|
@ -214,19 +215,19 @@ protected string HandleJsonSelector(SelectorBlock selector, JToken parentObj, Di
|
|||
if (selector.Selector != null)
|
||||
{
|
||||
var selectorSelector = ApplyGoTemplateText(selector.Selector.TrimStart('.'), variables);
|
||||
selectorSelector = JsonParseFieldSelector(parentObj, selectorSelector);
|
||||
var fieldSelector = JsonParseFieldSelector(parentObj, selectorSelector);
|
||||
|
||||
JToken selection = null;
|
||||
if (selectorSelector != null)
|
||||
if (fieldSelector != null)
|
||||
{
|
||||
selection = parentObj.SelectToken(selectorSelector);
|
||||
selection = parentObj.SelectToken(fieldSelector);
|
||||
}
|
||||
|
||||
if (selection == null)
|
||||
{
|
||||
if (required)
|
||||
{
|
||||
throw new Exception(string.Format("Selector \"{0}\" didn't match {1}", selectorSelector, parentObj.ToString()));
|
||||
throw new Exception($"Selector \"{selectorSelector}\" didn't match {parentObj.ToString(Formatting.None)}");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
@ -234,7 +235,7 @@ protected string HandleJsonSelector(SelectorBlock selector, JToken parentObj, Di
|
|||
|
||||
if (selection.Type is JTokenType.Array)
|
||||
{
|
||||
// turn this json array into a comma delimited string
|
||||
// turn this json array into a comma-delimited string
|
||||
var valueArray = selection.Value<JArray>();
|
||||
value = string.Join(",", valueArray);
|
||||
}
|
||||
|
|
@ -259,7 +260,7 @@ protected string HandleJsonSelector(SelectorBlock selector, JToken parentObj, Di
|
|||
{
|
||||
if (required)
|
||||
{
|
||||
throw new Exception($"None of the case selectors \"{string.Join(",", selector.Case)}\" matched {parentObj}");
|
||||
throw new Exception($"None of the case selectors \"{string.Join(",", selector.Case)}\" matched {parentObj.ToString(Formatting.None)}");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public IList<ReleaseInfo> ParseResponse(IndexerResponse indexerResponse)
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Trace(ex, "Failed to parse JSON rows count.");
|
||||
_logger.Debug(ex, "Failed to parse JSON rows count.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue