Add WebException handlers to prevent them reaching the UI.

This commit is contained in:
Taloth Saldono 2016-03-17 20:53:11 +01:00
parent 2d96914bfa
commit 1154e0eeb3
6 changed files with 37 additions and 3 deletions

View File

@ -229,6 +229,10 @@ namespace NzbDrone.Core.Download.Clients.Deluge
throw new DownloadClientException("Unable to connect to Deluge, please check your settings", ex); throw new DownloadClientException("Unable to connect to Deluge, please check your settings", ex);
} }
} }
catch (WebException ex)
{
throw new DownloadClientException("Unable to connect to Deluge, please check your settings", ex);
}
} }
private void AuthenticateClient(JsonRpcRequestBuilder requestBuilder, DelugeSettings settings, bool reauthenticate = false) private void AuthenticateClient(JsonRpcRequestBuilder requestBuilder, DelugeSettings settings, bool reauthenticate = false)

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net;
using Newtonsoft.Json; using Newtonsoft.Json;
using NLog; using NLog;
using NzbDrone.Common.Cache; using NzbDrone.Common.Cache;
@ -158,6 +159,10 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex
{ {
throw new DownloadClientException("Unable to connect to NZBVortex, please check your settings", ex); throw new DownloadClientException("Unable to connect to NZBVortex, please check your settings", ex);
} }
catch (WebException ex)
{
throw new DownloadClientException("Unable to connect to NZBVortex, please check your settings", ex);
}
} }
private void AuthenticateClient(HttpRequestBuilder requestBuilder, NzbVortexSettings settings, bool reauthenticate = false) private void AuthenticateClient(HttpRequestBuilder requestBuilder, NzbVortexSettings settings, bool reauthenticate = false)

View File

@ -174,6 +174,10 @@ namespace NzbDrone.Core.Download.Clients.Nzbget
throw new DownloadClientException("Unable to connect to NzbGet. " + ex.Message, ex); throw new DownloadClientException("Unable to connect to NzbGet. " + ex.Message, ex);
} }
catch (WebException ex)
{
throw new DownloadClientException("Unable to connect to NzbGet. " + ex.Message, ex);
}
_logger.Trace("Response: {0}", response.Content); _logger.Trace("Response: {0}", response.Content);

View File

@ -5,6 +5,7 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Common.Serializer; using NzbDrone.Common.Serializer;
using NzbDrone.Core.Download.Clients.Sabnzbd.Responses; using NzbDrone.Core.Download.Clients.Sabnzbd.Responses;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using System.Net;
namespace NzbDrone.Core.Download.Clients.Sabnzbd namespace NzbDrone.Core.Download.Clients.Sabnzbd
{ {
@ -167,6 +168,10 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd
{ {
throw new DownloadClientException("Unable to connect to SABnzbd, please check your settings", ex); throw new DownloadClientException("Unable to connect to SABnzbd, please check your settings", ex);
} }
catch (WebException ex)
{
throw new DownloadClientException("Unable to connect to SABnzbd, please check your settings", ex);
}
_logger.Trace("Response: {0}", response.Content); _logger.Trace("Response: {0}", response.Content);

View File

@ -160,9 +160,13 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
} }
else else
{ {
throw new DownloadClientException("Failed to connect to download client", ex); throw new DownloadClientException("Failed to connect to qBitTorrent, check your settings.", ex);
} }
} }
catch (WebException ex)
{
throw new DownloadClientException("Failed to connect to qBitTorrent, please check your settings.", ex);
}
return Json.Deserialize<TResult>(response.Content); return Json.Deserialize<TResult>(response.Content);
} }
@ -201,7 +205,11 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent
throw new DownloadClientAuthenticationException("Failed to authenticate with qbitTorrent.", ex); throw new DownloadClientAuthenticationException("Failed to authenticate with qbitTorrent.", ex);
} }
throw; throw new DownloadClientException("Failed to connect to qBitTorrent, please check your settings.", ex);
}
catch (WebException ex)
{
throw new DownloadClientException("Failed to connect to qBitTorrent, please check your settings.", ex);
} }
if (response.Content != "Ok.") // returns "Fails." on bad login if (response.Content != "Ok.") // returns "Fails." on bad login

View File

@ -193,6 +193,10 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
throw new DownloadClientException("Unable to connect to Deluge, please check your settings", ex); throw new DownloadClientException("Unable to connect to Deluge, please check your settings", ex);
} }
} }
catch (WebException ex)
{
throw new DownloadClientException("Unable to connect to Deluge, please check your settings", ex);
}
return Json.Deserialize<UTorrentResponse>(response.Content); return Json.Deserialize<UTorrentResponse>(response.Content);
} }
@ -230,7 +234,11 @@ namespace NzbDrone.Core.Download.Clients.UTorrent
throw new DownloadClientAuthenticationException("Failed to authenticate with uTorrent."); throw new DownloadClientAuthenticationException("Failed to authenticate with uTorrent.");
} }
throw; throw new DownloadClientException("Unable to connect to uTorrent, please check your settings", ex);
}
catch (WebException ex)
{
throw new DownloadClientException("Unable to connect to uTorrent, please check your settings", ex);
} }
cookies = response.GetCookies(); cookies = response.GetCookies();