From 2771688e96503148485a2b91ecf1525070cdd7c2 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Wed, 24 Sep 2025 12:23:00 +0200 Subject: [PATCH] ExceptionFilter should only explicitly set exit code in catch not finally --- .../Filters/CatchExceptionFilter.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/tooling/Elastic.Documentation.Tooling/Filters/CatchExceptionFilter.cs b/src/tooling/Elastic.Documentation.Tooling/Filters/CatchExceptionFilter.cs index d4f3afd0c..a1765a88b 100644 --- a/src/tooling/Elastic.Documentation.Tooling/Filters/CatchExceptionFilter.cs +++ b/src/tooling/Elastic.Documentation.Tooling/Filters/CatchExceptionFilter.cs @@ -20,7 +20,6 @@ public override async Task InvokeAsync(ConsoleAppContext context, Cancel cancell logger.LogInformation("Received CTRL+C cancelling"); _cancelKeyPressed = true; }; - var error = false; try { await Next.InvokeAsync(context, cancellationToken); @@ -32,14 +31,10 @@ public override async Task InvokeAsync(ConsoleAppContext context, Cancel cancell logger.LogInformation("Cancellation requested, exiting."); return; } - error = true; _ = collector.StartAsync(cancellationToken); collector.EmitGlobalError($"Global unhandled exception: {ex.Message}", ex); await collector.StopAsync(cancellationToken); - } - finally - { - Environment.ExitCode = error ? 1 : 0; + Environment.ExitCode = 1; } } }