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;
10
10
public sealed class CatchExceptionFilter ( ConsoleAppFilter next , ILogger < CatchExceptionFilter > logger )
11
11
: ConsoleAppFilter ( next )
12
12
{
13
+ private bool _cancelKeyPressed ;
13
14
public override async Task InvokeAsync ( ConsoleAppContext context , Cancel cancellationToken )
14
15
{
16
+ Console . CancelKeyPress += ( sender , e ) =>
17
+ {
18
+ logger . LogInformation ( "Received CTRL+C cancelling" ) ;
19
+ _cancelKeyPressed = true ;
20
+ } ;
15
21
try
16
22
{
17
23
await Next . InvokeAsync ( context , cancellationToken ) ;
18
24
}
19
25
catch ( Exception ex )
20
26
{
21
- if ( ex is OperationCanceledException )
27
+ if ( ex is OperationCanceledException && cancellationToken . IsCancellationRequested && _cancelKeyPressed )
22
28
{
23
29
logger . LogInformation ( "Cancellation requested, exiting." ) ;
24
30
return ;
You can’t perform that action at this time.
0 commit comments