-
Notifications
You must be signed in to change notification settings - Fork 413
Closed
Description
When using CommandHandler.Create(MethodInfo) with an async method, if an exception is thrown, the details are not printed to the console.
class Program
{
public void TestCommand()
{
throw new InvalidOperationException();
}
public async void TestCommandAsync()
{
throw new InvalidOperationException();
}
static int Main(string[] args)
{
return new CommandLineBuilder(new RootCommand()
{
new Command("test")
{
Handler = CommandHandler.Create(typeof(Program).GetMethod("TestCommand"))
},
new Command("test-async")
{
Handler = CommandHandler.Create(typeof(Program).GetMethod("TestCommandAsync"))
}
})
.UseDefaults()
.Build()
.Invoke(args);
}
}This is the output generated by running both commands:
For the async method, only Unhandled exception is printed.
The behavior is the same if we use:
static async Task<int> Main(string[] args)
{
return await new CommandLineBuilder(new RootCommand()
...
.InvokeAsync(args);Is there a way to get the full exception details printed to the console when using async commands?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels
