public async Task <FeedVerificationResult> VerifyFeedAsync(string source, bool authenticateIfRequired = false, CancellationToken cancellationToken = default)
        {
            Argument.IsNotNull(() => source);

            var result = FeedVerificationResult.Valid;

            StringBuilder errorMessage = new StringBuilder($"Failed to verify feed '{source}'");

            Log.Debug("Verifying feed '{0}'", source);

            try
            {
                var packageSource = new PackageSource(source);

                var repository = _repositoryProvider.CreateRepository(packageSource);

                try
                {
                    var searchResource = await repository.GetResourceAsync <PackageSearchResource>();

                    var metadata = await searchResource.SearchAsync(string.Empty, new SearchFilter(false), 0, 1, _nugetLogger, cancellationToken);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            catch (FatalProtocolException ex)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    //cancel operation
                    throw new OperationCanceledException("Verification was canceled", ex, cancellationToken);
                }
                result = FatalProtocolExceptionHandler.HandleException(ex, source);
            }
            catch (WebException ex)
            {
                result = WebExceptionHandler.HandleException(ex, source);
            }
            catch (UriFormatException ex)
            {
                errorMessage.Append(", a UriFormatException occurred");
                Log.Debug(ex, errorMessage.ToString());

                result = FeedVerificationResult.Invalid;
            }
            catch (Exception ex) when(!cancellationToken.IsCancellationRequested)
            {
                Log.Debug(ex, errorMessage.ToString());

                result = FeedVerificationResult.Invalid;
            }

            Log.Debug("Verified feed '{0}', result is '{1}'", source, result);

            return(result);
        }
        public FeedVerificationResult HandleException(FatalProtocolException exception, string source)
        {
            try
            {
                var innerException = exception.InnerException;

                if (innerException is null)
                {
                    //handle based on protocol error messages
                    if (exception.HidesUnauthorizedError())
                    {
                        return(FeedVerificationResult.AuthenticationRequired);
                    }
                    if (exception.HidesForbiddenError())
                    {
                        return(FeedVerificationResult.AuthorizationRequired);
                    }
                }
                else
                {
                    if (innerException is WebException)
                    {
                        WebExceptionHandler.HandleException(innerException as WebException, source);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Debug(ex, "Failed to verify feed '{0}'", source);
            }

            return(FeedVerificationResult.Invalid);
        }