2016-04-19 22:51:32 -05:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using System;
|
2016-12-16 10:23:26 -08:00
|
|
|
|
using Microsoft.DotNet.Tools;
|
2016-04-19 22:51:32 -05:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.CommandLine
|
|
|
|
|
{
|
|
|
|
|
internal class CommandParsingException : Exception
|
|
|
|
|
{
|
2017-03-13 13:29:03 -07:00
|
|
|
|
private readonly bool _isRequireSubCommandMissing;
|
|
|
|
|
|
|
|
|
|
public CommandParsingException(string message) : base(message)
|
|
|
|
|
{
|
|
|
|
|
Data.Add("CLI_User_Displayed_Exception", true);
|
|
|
|
|
}
|
2016-12-16 10:23:26 -08:00
|
|
|
|
|
2016-12-16 06:41:47 -10:00
|
|
|
|
public CommandParsingException(
|
|
|
|
|
CommandLineApplication command,
|
|
|
|
|
string message,
|
|
|
|
|
bool isRequireSubCommandMissing = false)
|
2017-03-13 13:29:03 -07:00
|
|
|
|
: this(message)
|
2016-04-19 22:51:32 -05:00
|
|
|
|
{
|
|
|
|
|
Command = command;
|
2016-12-16 10:23:26 -08:00
|
|
|
|
_isRequireSubCommandMissing = isRequireSubCommandMissing;
|
2016-04-19 22:51:32 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CommandLineApplication Command { get; }
|
2016-12-16 10:23:26 -08:00
|
|
|
|
|
|
|
|
|
public override string Message
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return _isRequireSubCommandMissing
|
2017-03-13 13:29:03 -07:00
|
|
|
|
? CommonLocalizableStrings.RequiredCommandNotPassed
|
|
|
|
|
: base.Message;
|
2016-12-16 10:23:26 -08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-04-19 22:51:32 -05:00
|
|
|
|
}
|
2017-03-13 13:29:03 -07:00
|
|
|
|
}
|