From b1859d41e861630a95357bf21bb46af6c4fb5686 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 7 Oct 2015 17:42:29 -0400 Subject: update collection menus --- .../HttpClientManager/HttpClientManager.cs | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs') diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index 86aae959d..2578602a1 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -465,7 +465,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager } catch (OperationCanceledException ex) { - var exception = GetCancellationException(options.Url, options.CancellationToken, ex); + var exception = GetCancellationException(options, options.CancellationToken, ex); var httpException = exception as HttpException; @@ -497,7 +497,10 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// HttpException. private HttpException GetException(WebException ex, HttpRequestOptions options) { - _logger.ErrorException("Error getting response from " + options.Url, ex); + if (options.LogErrors) + { + _logger.ErrorException("Error getting response from " + options.Url, ex); + } var exception = new HttpException(ex.Message, ex); @@ -710,10 +713,13 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager if (operationCanceledException != null) { - return GetCancellationException(options.Url, options.CancellationToken, operationCanceledException); + return GetCancellationException(options, options.CancellationToken, operationCanceledException); } - _logger.ErrorException("Error getting response from " + options.Url, ex); + if (options.LogErrors) + { + _logger.ErrorException("Error getting response from " + options.Url, ex); + } return ex; } @@ -785,18 +791,21 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// /// Throws the cancellation exception. /// - /// The URL. + /// The options. /// The cancellation token. /// The exception. /// Exception. - private Exception GetCancellationException(string url, CancellationToken cancellationToken, OperationCanceledException exception) + private Exception GetCancellationException(HttpRequestOptions options, CancellationToken cancellationToken, OperationCanceledException exception) { // If the HttpClient's timeout is reached, it will cancel the Task internally if (!cancellationToken.IsCancellationRequested) { - var msg = string.Format("Connection to {0} timed out", url); + var msg = string.Format("Connection to {0} timed out", options.Url); - _logger.Error(msg); + if (options.LogErrors) + { + _logger.Error(msg); + } // Throw an HttpException so that the caller doesn't think it was cancelled by user code return new HttpException(msg, exception) -- cgit v1.2.3