From dcf434abd3565a26458778510778c4f2129542ad Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Mon, 13 Oct 2014 11:07:05 -0700 Subject: [PATCH] better error messages when download client connection fails --- src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs | 6 +++--- .../HealthCheck/Checks/DownloadClientCheck.cs | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs index 7ead65201..d2081b611 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetProxy.cs @@ -185,15 +185,15 @@ private IRestRequest BuildRequest(JsonRequest jsonRequest) request.JsonSerializer = new JsonNetSerializer(); request.RequestFormat = DataFormat.Json; request.AddBody(jsonRequest); - + return request; } private void CheckForError(IRestResponse response) { - if (response.ResponseStatus != ResponseStatus.Completed) + if (response.ErrorException != null) { - throw new DownloadClientException("Unable to connect to NzbGet, please check your settings", response.ErrorException); + throw new DownloadClientException("Unable to connect to NzbGet. " + response.ErrorException.Message, response.ErrorException); } if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) diff --git a/src/NzbDrone.Core/HealthCheck/Checks/DownloadClientCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/DownloadClientCheck.cs index f86bdf679..624057ee1 100644 --- a/src/NzbDrone.Core/HealthCheck/Checks/DownloadClientCheck.cs +++ b/src/NzbDrone.Core/HealthCheck/Checks/DownloadClientCheck.cs @@ -15,9 +15,9 @@ public DownloadClientCheck(IProvideDownloadClient downloadClientProvider) public override HealthCheck Check() { - var downloadClients = _downloadClientProvider.GetDownloadClients(); + var downloadClients = _downloadClientProvider.GetDownloadClients().ToList(); - if (downloadClients.Count() == 0) + if (!downloadClients.Any()) { return new HealthCheck(GetType(), HealthCheckResult.Warning, "No download client is available"); } @@ -29,9 +29,9 @@ public override HealthCheck Check() downloadClient.GetItems(); } } - catch (Exception) + catch (Exception e) { - return new HealthCheck(GetType(), HealthCheckResult.Error, "Unable to communicate with download client"); + return new HealthCheck(GetType(), HealthCheckResult.Error, "Unable to communicate with download client " + e.Message); } return new HealthCheck(GetType());