From 6bdf5f5d6916b03a4dbef001bdf1da8fdd074530 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Mon, 16 Dec 2024 22:25:55 +0200 Subject: [PATCH] Use error message from Redacted response --- src/NzbDrone.Core/Indexers/Definitions/Redacted.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs b/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs index 761b101a0..fc20f3e73 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Redacted.cs @@ -8,6 +8,7 @@ using FluentValidation; using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; +using NzbDrone.Common.Serializer; using NzbDrone.Core.Annotations; using NzbDrone.Core.Configuration; using NzbDrone.Core.Indexers.Definitions.Gazelle; @@ -252,7 +253,9 @@ namespace NzbDrone.Core.Indexers.Definitions if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) { - throw new IndexerException(indexerResponse, $"Unexpected response status {indexerResponse.HttpResponse.StatusCode} code from indexer request"); + STJson.TryDeserialize(indexerResponse.Content, out var errorResponse); + + throw new IndexerException(indexerResponse, $"Unexpected response status {indexerResponse.HttpResponse.StatusCode} code from indexer request: {errorResponse?.Error ?? "Check the logs for more information."}"); } if (!indexerResponse.HttpResponse.Headers.ContentType.Contains(HttpAccept.Json.Value)) @@ -487,4 +490,9 @@ namespace NzbDrone.Core.Indexers.Definitions [FieldOption(Label = "Required", Hint = "Abort download if unable to use token")] Required = 2, } + + public class RedactedErrorResponse + { + public string Error { get; init; } + } }