commandlineparser / commandlineparser/commandline

WithParsed(async swallows exceptions

Ouverte
#773 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
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.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.