diff --git a/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs b/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs index 36247522f..df9d2e7b3 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/Nebulance.cs @@ -228,10 +228,21 @@ 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"); + throw new IndexerException(indexerResponse, "Unexpected response status '{0}' code from indexer request", indexerResponse.HttpResponse.StatusCode); } - var jsonResponse = STJson.Deserialize>(indexerResponse.HttpResponse.Content); + JsonRpcResponse jsonResponse; + + try + { + jsonResponse = STJson.Deserialize>(indexerResponse.HttpResponse.Content); + } + catch (Exception ex) + { + STJson.TryDeserialize>(indexerResponse.HttpResponse.Content, out var response); + + throw new IndexerException(indexerResponse, "Unexpected response from indexer request: {0}", ex, response?.Result ?? ex.Message); + } if (jsonResponse.Error != null || jsonResponse.Result == null) { diff --git a/src/NzbDrone.Core/Indexers/Exceptions/IndexerException.cs b/src/NzbDrone.Core/Indexers/Exceptions/IndexerException.cs index 629f596a8..f0f1c2899 100644 --- a/src/NzbDrone.Core/Indexers/Exceptions/IndexerException.cs +++ b/src/NzbDrone.Core/Indexers/Exceptions/IndexerException.cs @@ -1,23 +1,34 @@ -using NzbDrone.Common.Exceptions; +using System; +using NzbDrone.Common.Exceptions; namespace NzbDrone.Core.Indexers.Exceptions { public class IndexerException : NzbDroneException { - private readonly IndexerResponse _indexerResponse; + public IndexerResponse Response { get; } + + public IndexerException(IndexerResponse response, string message) + : base(message) + { + Response = response; + } + + public IndexerException(IndexerResponse response, string message, Exception innerException) + : base(message, innerException) + { + Response = response; + } public IndexerException(IndexerResponse response, string message, params object[] args) : base(message, args) { - _indexerResponse = response; + Response = response; } - public IndexerException(IndexerResponse response, string message) - : base(message) + public IndexerException(IndexerResponse response, string message, Exception innerException, params object[] args) + : base(message, innerException, args) { - _indexerResponse = response; + Response = response; } - - public IndexerResponse Response => _indexerResponse; } }