commandlineparser / commandlineparser/commandline
WithParsed(async swallows exceptions
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 478
- PR merge metrics
- No merged PRs in 30d
Description
### Some examples of the use of WithParsed / WithParsedAsync with expected behavior
```
internal static class Program
{
private static void Main(string[] args)
{
Parser.Default.ParseArguments(args).WithParsed(_ => throw new Exception());
```
=> Unhandled exception. System.Exception: Exception of type 'System.Exception' was thrown.
As Expected.
```
internal static class Program
{
private static async Task Main(string[] args)
{
await Parser.Default.ParseArguments(args).WithParsedAsync(_ => throw new Exception());
```
=> Unhandled exception. System.Exception: Exception of type 'System.Exception' was thrown.
As Expected.
```
internal static class Program
{
private static async Task Main(string[] args)
{
await Parser.Default.ParseArguments(args).WithParsedAsync(async _ =>
{
await Task.CompletedTask; //just for demonstration
throw new Exception();
});
```
=> Unhandled exception. System.Exception: Exception of type 'System.Exception' was thrown.
As Expected.
### When using WithParsed with an async expresion in a synchrone context, it swallows the exception
```
internal static class Program
{
private static void Main(string[] args)
{
Parser.Default.ParseArguments(args).WithParsed(async _ =>
{
await Task.CompletedTask; //just for demonstration
throw new Exception();
});
```
=> Process finished with exit code 0.
Should also notify about Unhandled exception.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.