display CommandParsingException gracefully (#5493)
* display CommandParsing gracefully This set of changes handles CommandParsingException gracefuly (so as not to show the user a stack trace) and generalizes graceful exception display somewhat away from being type-specific. * fix compile error by inlining constant * remove unused test logging
This commit is contained in:
parent
5aded80a7b
commit
e8c5d23c29
8 changed files with 42 additions and 13 deletions
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.Cli.CommandLine;
|
||||
using Microsoft.DotNet.Configurer;
|
||||
using Microsoft.DotNet.PlatformAbstractions;
|
||||
using Microsoft.DotNet.Tools.Add;
|
||||
|
@ -76,9 +77,11 @@ namespace Microsoft.DotNet.Cli
|
|||
return ProcessArgs(args);
|
||||
}
|
||||
}
|
||||
catch (GracefulException e)
|
||||
catch (Exception e) when (e.ShouldBeDisplayedAsError())
|
||||
{
|
||||
Reporter.Error.WriteLine(CommandContext.IsVerbose() ? e.ToString().Red().Bold() : e.Message.Red().Bold());
|
||||
Reporter.Error.WriteLine(CommandContext.IsVerbose() ?
|
||||
e.ToString().Red().Bold() :
|
||||
e.Message.Red().Bold());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue