Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the format of tool exceptions and NuGet API exceptions to be graceful #36641

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Cli/Microsoft.DotNet.Cli.Utils/GracefulException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,9 @@ await Task.WhenAll(
throw new NuGetPackageNotFoundException(
string.Format(
LocalizableStrings.IsNotFoundInNuGetFeeds,
$"{packageIdentifier}::{versionRange}",
$"{packageIdentifier} of version range {versionRange}",
JL03-Yue marked this conversation as resolved.
Show resolved Hide resolved
string.Join(", ", packageSources.Select(source => source.Source))));
}

}

private async Task<(PackageSource, IPackageSearchMetadata)> GetLatestVersionInternalAsync(
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
{
Expand Down
3 changes: 2 additions & 1 deletion src/Cli/dotnet/ToolPackage/ToolPackageException.cs
Original file line number Diff line number Diff line change
@@ -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()
{
Expand Down