commandlineparser / commandlineparser/commandline
WithParsed(async swallows exceptions
- Langage dominant
- C#
- Étoiles
- 4.8k
- Forks
- 478
- Métriques de merge des PR
- Aucune PR mergée en 30 j
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.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.