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:
Jon Sequeira 2017-01-30 14:36:44 -08:00 committed by Piotr Puszkiewicz
parent 5aded80a7b
commit e8c5d23c29
8 changed files with 42 additions and 13 deletions

View file

@ -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;
}