Example #1
0
        private ValidationFailure TestConnection()
        {
            try
            {
                _proxy.GetVersion(Settings);
            }
            catch (DownloadClientAuthenticationException ex)
            {
                _logger.Error(ex, ex.Message);

                return(new NzbDroneValidationFailure("Password", "Authentication failed"));
            }
            catch (WebException ex)
            {
                _logger.Error(ex, "Unable to test connection");
                switch (ex.Status)
                {
                case WebExceptionStatus.ConnectFailure:
                    return(new NzbDroneValidationFailure("Host", "Unable to connect")
                    {
                        DetailedDescription = "Please verify the hostname and port."
                    });

                case WebExceptionStatus.ConnectionClosed:
                    return(new NzbDroneValidationFailure("UseSsl", "Verify SSL settings")
                    {
                        DetailedDescription = "Please verify your SSL configuration on both Deluge and NzbDrone."
                    });

                case WebExceptionStatus.SecureChannelFailure:
                    return(new NzbDroneValidationFailure("UseSsl", "Unable to connect through SSL")
                    {
                        DetailedDescription = "Drone is unable to connect to Deluge using SSL. This problem could be computer related. Please try to configure both drone and Deluge to not use SSL."
                    });

                default:
                    return(new NzbDroneValidationFailure(string.Empty, "Unknown exception: " + ex.Message));
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Failed to test connection");

                return(new NzbDroneValidationFailure("Host", "Unable to connect to Deluge")
                {
                    DetailedDescription = ex.Message
                });
            }

            return(null);
        }