From 18253a298e86432dd1c49055079966a1afa7160b Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Wed, 10 Mar 2021 21:43:43 +0100 Subject: [PATCH] Log Goodreads connection failures with more info. (cherry picked from commit 6672650b6b5e152e82fb3ad38a0a158d66c0b83d) --- .../Exceptions/NzbDroneClientException.cs | 9 ++++++++- .../MetadataSource/BookInfo/BookInfoException.cs | 6 ++++++ .../Goodreads/GoodreadsException.cs | 8 +++++++- .../GoodreadsSearchProxy/GoodreadsSearchProxy.cs | 15 +++++++++++---- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core/Exceptions/NzbDroneClientException.cs b/src/NzbDrone.Core/Exceptions/NzbDroneClientException.cs index ed44e447c..5c162ad4f 100644 --- a/src/NzbDrone.Core/Exceptions/NzbDroneClientException.cs +++ b/src/NzbDrone.Core/Exceptions/NzbDroneClientException.cs @@ -1,4 +1,5 @@ -using System.Net; +using System; +using System.Net; using NzbDrone.Common.Exceptions; namespace NzbDrone.Core.Exceptions @@ -13,6 +14,12 @@ namespace NzbDrone.Core.Exceptions StatusCode = statusCode; } + public NzbDroneClientException(HttpStatusCode statusCode, string message, Exception innerException, params object[] args) + : base(message, innerException, args) + { + StatusCode = statusCode; + } + public NzbDroneClientException(HttpStatusCode statusCode, string message) : base(message) { diff --git a/src/NzbDrone.Core/MetadataSource/BookInfo/BookInfoException.cs b/src/NzbDrone.Core/MetadataSource/BookInfo/BookInfoException.cs index 83044fa65..b0df3cc07 100644 --- a/src/NzbDrone.Core/MetadataSource/BookInfo/BookInfoException.cs +++ b/src/NzbDrone.Core/MetadataSource/BookInfo/BookInfoException.cs @@ -1,3 +1,4 @@ +using System; using System.Net; using NzbDrone.Core.Exceptions; @@ -14,5 +15,10 @@ namespace NzbDrone.Core.MetadataSource.BookInfo : base(HttpStatusCode.ServiceUnavailable, message, args) { } + + public BookInfoException(string message, Exception innerException, params object[] args) + : base(HttpStatusCode.ServiceUnavailable, message, innerException, args) + { + } } } diff --git a/src/NzbDrone.Core/MetadataSource/Goodreads/GoodreadsException.cs b/src/NzbDrone.Core/MetadataSource/Goodreads/GoodreadsException.cs index 748426b58..b166780a9 100644 --- a/src/NzbDrone.Core/MetadataSource/Goodreads/GoodreadsException.cs +++ b/src/NzbDrone.Core/MetadataSource/Goodreads/GoodreadsException.cs @@ -1,4 +1,5 @@ -using System.Net; +using System; +using System.Net; using NzbDrone.Core.Exceptions; namespace NzbDrone.Core.MetadataSource.Goodreads @@ -14,5 +15,10 @@ namespace NzbDrone.Core.MetadataSource.Goodreads : base(HttpStatusCode.ServiceUnavailable, message, args) { } + + public GoodreadsException(string message, Exception innerException, params object[] args) + : base(HttpStatusCode.ServiceUnavailable, message, innerException, args) + { + } } } diff --git a/src/NzbDrone.Core/MetadataSource/GoodreadsSearchProxy/GoodreadsSearchProxy.cs b/src/NzbDrone.Core/MetadataSource/GoodreadsSearchProxy/GoodreadsSearchProxy.cs index 981ef571f..aa41351ad 100644 --- a/src/NzbDrone.Core/MetadataSource/GoodreadsSearchProxy/GoodreadsSearchProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/GoodreadsSearchProxy/GoodreadsSearchProxy.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Net; using NLog; using NzbDrone.Common.Http; using NzbDrone.Core.Http; @@ -43,14 +44,20 @@ namespace NzbDrone.Core.MetadataSource.Goodreads return response.Resource; } - catch (HttpException) + catch (HttpException ex) { - throw new GoodreadsException("Search for '{0}' failed. Unable to communicate with Goodreads.", query); + _logger.Warn(ex); + throw new GoodreadsException("Search for '{0}' failed. Unable to communicate with Goodreads.", ex, query); + } + catch (WebException ex) + { + _logger.Warn(ex); + throw new GoodreadsException("Search for '{0}' failed. Unable to communicate with Goodreads.", ex, query, ex.Message); } catch (Exception ex) { - _logger.Warn(ex, ex.Message); - throw new GoodreadsException("Search for '{0}' failed. Invalid response received from Goodreads.", query); + _logger.Warn(ex); + throw new GoodreadsException("Search for '{0}' failed. Invalid response received from Goodreads.", ex, query); } } }