我有这本字典。
private Dictionary<string[], ICommand> commandsWithAttributes = new Dictionary<string[], ICommand>();
Run Code Online (Sandbox Code Playgroud)
我需要commandsWithAttributes按部分键查找元素。我的意思是:
"-?" -是我用来查找商品的钥匙。
({"-t","--thread"},ICommand)
({"-?","--help"},ICommand) <-这是我需要找到的。
例如,php 有类似 InvalidArgumentException 的异常,带有自定义消息“未找到当前组”。
我可以在代码中抛出这个异常。
if ($groupId === 0) {
throw new InvalidArgumentException('Current group not found');
}
Run Code Online (Sandbox Code Playgroud)
我可以继承这个异常并创建另一个子异常。
Perl 中的异常是如何工作的?