From 6672650b6b5e152e82fb3ad38a0a158d66c0b83d Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Wed, 10 Mar 2021 21:43:43 +0100 Subject: [PATCH] Log Skyhook connection failures with more info. --- .../Exceptions/NzbDroneClientException.cs | 11 +++++++++-- .../MetadataSource/SkyHook/SkyHookException.cs | 5 +++++ .../MetadataSource/SkyHook/SkyHookProxy.cs | 14 ++++++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core/Exceptions/NzbDroneClientException.cs b/src/NzbDrone.Core/Exceptions/NzbDroneClientException.cs index d9225eb2c..e0345a1b2 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 @@ -7,7 +8,13 @@ namespace NzbDrone.Core.Exceptions { public HttpStatusCode StatusCode { get; private set; } - public NzbDroneClientException(HttpStatusCode statusCode, string message, params object[] args) : base(message, args) + public NzbDroneClientException(HttpStatusCode statusCode, string message, params object[] args) + : base(message, args) + { + StatusCode = statusCode; + } + public NzbDroneClientException(HttpStatusCode statusCode, string message, Exception innerException, params object[] args) + : base(message, innerException, args) { StatusCode = statusCode; } diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookException.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookException.cs index a9591fd6b..c449f24bf 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookException.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookException.cs @@ -13,5 +13,10 @@ namespace NzbDrone.Core.MetadataSource.SkyHook : base(HttpStatusCode.ServiceUnavailable, message, args) { } + + public SkyHookException(string message, Exception innerException, params object[] args) + : base(HttpStatusCode.ServiceUnavailable, innerException, message, args) + { + } } } diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index baaecfbbb..b78898e6a 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -109,14 +109,20 @@ namespace NzbDrone.Core.MetadataSource.SkyHook return httpResponse.Resource.SelectList(MapSearchResult); } - catch (HttpException) + catch (HttpException ex) { - throw new SkyHookException("Search for '{0}' failed. Unable to communicate with SkyHook.", title); + _logger.Warn(ex); + throw new SkyHookException("Search for '{0}' failed. Unable to communicate with SkyHook.", ex, title); + } + catch (WebException ex) + { + _logger.Warn(ex); + throw new SkyHookException("Search for '{0}' failed. Unable to communicate with SkyHook.", ex, title, ex.Message); } catch (Exception ex) { - _logger.Warn(ex, ex.Message); - throw new SkyHookException("Search for '{0}' failed. Invalid response received from SkyHook.", title); + _logger.Warn(ex); + throw new SkyHookException("Search for '{0}' failed. Invalid response received from SkyHook.", ex, title); } }