From 36169a47bdf9a43b1df11197bdee1f1d9d6314ea Mon Sep 17 00:00:00 2001 From: annie <59816815+JL03-Yue@users.noreply.github.com> Date: Thu, 2 Nov 2023 17:39:44 -0700 Subject: [PATCH] change tool exception and nuget exceptions to be GracefulException --- src/Cli/Microsoft.DotNet.Cli.Utils/GracefulException.cs | 4 ++++ .../dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs | 3 +-- src/Cli/dotnet/NugetPackageDownloader/ToolPackageException.cs | 4 +++- src/Cli/dotnet/ToolPackage/ToolPackageException.cs | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Cli/Microsoft.DotNet.Cli.Utils/GracefulException.cs b/src/Cli/Microsoft.DotNet.Cli.Utils/GracefulException.cs index 5fb7a24f9244..8de30ca1a06f 100644 --- a/src/Cli/Microsoft.DotNet.Cli.Utils/GracefulException.cs +++ b/src/Cli/Microsoft.DotNet.Cli.Utils/GracefulException.cs @@ -8,6 +8,10 @@ public class GracefulException : Exception public bool IsUserError { get; } = true; public string VerboseMessage { get; } = string.Empty; + public GracefulException() + { + } + public GracefulException(string message) : base(message) { Data.Add(ExceptionExtensions.CLI_User_Displayed_Exception, true); diff --git a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs index 4b7e57978835..ca69f1254009 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs @@ -450,10 +450,9 @@ await Task.WhenAll( throw new NuGetPackageNotFoundException( string.Format( LocalizableStrings.IsNotFoundInNuGetFeeds, - $"{packageIdentifier}::{versionRange}", + $"{packageIdentifier} of version range {versionRange}", string.Join(", ", packageSources.Select(source => source.Source)))); } - } private async Task<(PackageSource, IPackageSearchMetadata)> GetLatestVersionInternalAsync( diff --git a/src/Cli/dotnet/NugetPackageDownloader/ToolPackageException.cs b/src/Cli/dotnet/NugetPackageDownloader/ToolPackageException.cs index b2475bdeefcd..8e087629e471 100644 --- a/src/Cli/dotnet/NugetPackageDownloader/ToolPackageException.cs +++ b/src/Cli/dotnet/NugetPackageDownloader/ToolPackageException.cs @@ -1,9 +1,11 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Microsoft.DotNet.Cli.Utils; + namespace Microsoft.DotNet.Cli.NuGetPackageDownloader { - internal class NuGetPackageInstallerException : Exception + internal class NuGetPackageInstallerException : GracefulException { public NuGetPackageInstallerException() { diff --git a/src/Cli/dotnet/ToolPackage/ToolPackageException.cs b/src/Cli/dotnet/ToolPackage/ToolPackageException.cs index 5617dbc72f20..0614f662482e 100644 --- a/src/Cli/dotnet/ToolPackage/ToolPackageException.cs +++ b/src/Cli/dotnet/ToolPackage/ToolPackageException.cs @@ -1,9 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Microsoft.DotNet.Cli.Utils; namespace Microsoft.DotNet.ToolPackage { - internal class ToolPackageException : Exception + internal class ToolPackageException : GracefulException { public ToolPackageException() {