mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Improve error messaging for not finding JSON selectors in Cardigann
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Text;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using AngleSharp.Dom;
|
using AngleSharp.Dom;
|
||||||
using Microsoft.AspNetCore.WebUtilities;
|
using Microsoft.AspNetCore.WebUtilities;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
@@ -214,19 +215,19 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
|||||||
if (selector.Selector != null)
|
if (selector.Selector != null)
|
||||||
{
|
{
|
||||||
var selectorSelector = ApplyGoTemplateText(selector.Selector.TrimStart('.'), variables);
|
var selectorSelector = ApplyGoTemplateText(selector.Selector.TrimStart('.'), variables);
|
||||||
selectorSelector = JsonParseFieldSelector(parentObj, selectorSelector);
|
var fieldSelector = JsonParseFieldSelector(parentObj, selectorSelector);
|
||||||
|
|
||||||
JToken selection = null;
|
JToken selection = null;
|
||||||
if (selectorSelector != null)
|
if (fieldSelector != null)
|
||||||
{
|
{
|
||||||
selection = parentObj.SelectToken(selectorSelector);
|
selection = parentObj.SelectToken(fieldSelector);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selection == null)
|
if (selection == null)
|
||||||
{
|
{
|
||||||
if (required)
|
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;
|
return null;
|
||||||
@@ -234,7 +235,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
|||||||
|
|
||||||
if (selection.Type is JTokenType.Array)
|
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>();
|
var valueArray = selection.Value<JArray>();
|
||||||
value = string.Join(",", valueArray);
|
value = string.Join(",", valueArray);
|
||||||
}
|
}
|
||||||
@@ -259,7 +260,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
|||||||
{
|
{
|
||||||
if (required)
|
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;
|
return null;
|
||||||
|
@@ -105,7 +105,7 @@ namespace NzbDrone.Core.Indexers.Definitions.Cardigann
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Trace(ex, "Failed to parse JSON rows count.");
|
_logger.Debug(ex, "Failed to parse JSON rows count.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user