From 2960fc37d9b04b57b3d8f50b1de2a3d5e40220fc Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 16 Jan 2024 04:57:22 +0200 Subject: [PATCH] Fixed: (FL) Improve error message for service unavailable --- .../Indexers/Definitions/FileList/FileListApi.cs | 5 +++++ .../Indexers/Definitions/FileList/FileListParser.cs | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Indexers/Definitions/FileList/FileListApi.cs b/src/NzbDrone.Core/Indexers/Definitions/FileList/FileListApi.cs index 6f1fdc12e..8b1e4253a 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/FileList/FileListApi.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/FileList/FileListApi.cs @@ -38,3 +38,8 @@ public class FileListTorrent [JsonPropertyName("small_description")] public string SmallDescription { get; set; } } + +public class FileListErrorResponse +{ + public string Error { get; set; } +} diff --git a/src/NzbDrone.Core/Indexers/Definitions/FileList/FileListParser.cs b/src/NzbDrone.Core/Indexers/Definitions/FileList/FileListParser.cs index 9c43e639f..9fee9dd3b 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/FileList/FileListParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/FileList/FileListParser.cs @@ -28,9 +28,14 @@ public class FileListParser : IParseIndexerResponse throw new IndexerException(indexerResponse, "Unexpected response status {0} code from indexer request", indexerResponse.HttpResponse.StatusCode); } + if (indexerResponse.Content.StartsWith("{\"error2\"") && STJson.TryDeserialize(indexerResponse.Content, out var errorResponse)) + { + throw new IndexerException(indexerResponse, "Unexpected response from indexer request: {0}", errorResponse.Error); + } + if (!indexerResponse.HttpResponse.Headers.ContentType.Contains(HttpAccept.Json.Value)) { - throw new IndexerException(indexerResponse, $"Unexpected response header {indexerResponse.HttpResponse.Headers.ContentType} from indexer request, expected {HttpAccept.Json.Value}"); + throw new IndexerException(indexerResponse, "Unexpected response header {0} from indexer request, expected {1}", indexerResponse.HttpResponse.Headers.ContentType, HttpAccept.Json.Value); } var releaseInfos = new List();