throw exception on parse errors

This commit is contained in:
Jon Sequeira 2017-03-13 13:29:03 -07:00
parent 11b7e7e449
commit 204d8594bf
15 changed files with 48 additions and 21 deletions

View file

@ -8,18 +8,21 @@ namespace Microsoft.DotNet.Cli.CommandLine
{
internal class CommandParsingException : Exception
{
private bool _isRequireSubCommandMissing;
private readonly bool _isRequireSubCommandMissing;
public CommandParsingException(string message) : base(message)
{
Data.Add("CLI_User_Displayed_Exception", true);
}
public CommandParsingException(
CommandLineApplication command,
string message,
bool isRequireSubCommandMissing = false)
: base(message)
: this(message)
{
Command = command;
_isRequireSubCommandMissing = isRequireSubCommandMissing;
Data.Add("CLI_User_Displayed_Exception", true);
}
public CommandLineApplication Command { get; }
@ -29,9 +32,9 @@ namespace Microsoft.DotNet.Cli.CommandLine
get
{
return _isRequireSubCommandMissing
? CommonLocalizableStrings.RequiredCommandNotPassed
: base.Message;
? CommonLocalizableStrings.RequiredCommandNotPassed
: base.Message;
}
}
}
}
}