Orc.NuGetExplorer.NuGetFeedVerificationService.HandleWebException C# (CSharp) Method

HandleWebException() private static method

private static HandleWebException ( WebException exception, string source ) : FeedVerificationResult
exception System.Net.WebException
source string
return FeedVerificationResult
        private static FeedVerificationResult HandleWebException(WebException exception, string source)
        {
            try
            {
                var httpWebResponse = (HttpWebResponse)exception.Response;
                if (ReferenceEquals(httpWebResponse, null))
                {
                    return FeedVerificationResult.Invalid;
                }

                if ((int)httpWebResponse.StatusCode == 403)
                {
                    return FeedVerificationResult.Valid;
                }

                if (exception.Status == WebExceptionStatus.ProtocolError)
                {
                    return httpWebResponse.StatusCode == HttpStatusCode.Unauthorized
                        ? FeedVerificationResult.AuthenticationRequired
                        : FeedVerificationResult.Invalid;
                }                
            }
            catch (Exception ex)
            {
                Log.Debug(ex, "Failed to verify feed '{0}'", source);
            }

            return FeedVerificationResult.Invalid;
        }
        #endregion