File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
src/tooling/Elastic.Documentation.Tooling/Filters Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -10,15 +10,21 @@ namespace Elastic.Documentation.Tooling.Filters;
1010public sealed class CatchExceptionFilter ( ConsoleAppFilter next , ILogger < CatchExceptionFilter > logger )
1111 : ConsoleAppFilter ( next )
1212{
13+ private bool _cancelKeyPressed ;
1314 public override async Task InvokeAsync ( ConsoleAppContext context , Cancel cancellationToken )
1415 {
16+ Console . CancelKeyPress += ( sender , e ) =>
17+ {
18+ logger . LogInformation ( "Received CTRL+C cancelling" ) ;
19+ _cancelKeyPressed = true ;
20+ } ;
1521 try
1622 {
1723 await Next . InvokeAsync ( context , cancellationToken ) ;
1824 }
1925 catch ( Exception ex )
2026 {
21- if ( ex is OperationCanceledException )
27+ if ( ex is OperationCanceledException && cancellationToken . IsCancellationRequested && _cancelKeyPressed )
2228 {
2329 logger . LogInformation ( "Cancellation requested, exiting." ) ;
2430 return ;
You can’t perform that action at this time.
0 commit comments