File tree 2 files changed +27
-2
lines changed
src/DotNetCampus.CommandLine 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 1
1
using System . Collections . Concurrent ;
2
2
using System . ComponentModel ;
3
3
using DotNetCampus . Cli . Compiler ;
4
+ using DotNetCampus . Cli . Exceptions ;
4
5
using DotNetCampus . Cli . Utils . Handlers ;
5
6
6
7
namespace DotNetCampus . Cli ;
@@ -195,8 +196,9 @@ public Task<int> RunAsync()
195
196
196
197
if ( handler is null )
197
198
{
198
- throw new InvalidOperationException (
199
- $ "No command handler found for verb '{ _commandLine . GuessedVerbName } '. Please ensure that the command handler is registered correctly.") ;
199
+ throw new CommandVerbNotFoundException (
200
+ $ "No command handler found for verb '{ _commandLine . GuessedVerbName } '. Please ensure that the command handler is registered correctly.",
201
+ _commandLine . GuessedVerbName ) ;
200
202
}
201
203
202
204
return handler . RunAsync ( ) ;
Original file line number Diff line number Diff line change
1
+ namespace DotNetCampus . Cli . Exceptions ;
2
+
3
+ /// <summary>
4
+ /// 表示输入的命令行在匹配多个命令行参数选项、谓词或处理器时,没有任何一个匹配到的异常。
5
+ /// </summary>
6
+ public class CommandVerbNotFoundException : CommandLineException
7
+ {
8
+ /// <summary>
9
+ /// 获取命令行谓词的名称。
10
+ /// </summary>
11
+ public string ? VerbName { get ; }
12
+
13
+ /// <summary>
14
+ /// 初始化 <see cref="CommandVerbNotFoundException"/> 类的新实例。
15
+ /// </summary>
16
+ /// <param name="message">异常提示信息。</param>
17
+ /// <param name="verbName">命令行谓词的名称。</param>
18
+ public CommandVerbNotFoundException ( string message , string ? verbName )
19
+ : base ( message )
20
+ {
21
+ VerbName = verbName ;
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments