Skip to content

Commit ec3d29b

Browse files
authored
ExceptionFilter should only explicitly set exit code in catch not finally (#1937)
1 parent a0748da commit ec3d29b

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/tooling/Elastic.Documentation.Tooling/Filters/CatchExceptionFilter.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public override async Task InvokeAsync(ConsoleAppContext context, Cancel cancell
2020
logger.LogInformation("Received CTRL+C cancelling");
2121
_cancelKeyPressed = true;
2222
};
23-
var error = false;
2423
try
2524
{
2625
await Next.InvokeAsync(context, cancellationToken);
@@ -32,14 +31,10 @@ public override async Task InvokeAsync(ConsoleAppContext context, Cancel cancell
3231
logger.LogInformation("Cancellation requested, exiting.");
3332
return;
3433
}
35-
error = true;
3634
_ = collector.StartAsync(cancellationToken);
3735
collector.EmitGlobalError($"Global unhandled exception: {ex.Message}", ex);
3836
await collector.StopAsync(cancellationToken);
39-
}
40-
finally
41-
{
42-
Environment.ExitCode = error ? 1 : 0;
37+
Environment.ExitCode = 1;
4338
}
4439
}
4540
}

0 commit comments

Comments
 (0)