@@ -12,6 +12,7 @@ import { LintTrigger } from '../services/cfnLint/CfnLintService';
1212import { ValidationTrigger } from '../services/guard/GuardService' ;
1313import { publishValidationDiagnostics } from '../stacks/actions/StackActionOperations' ;
1414import { LoggerFactory } from '../telemetry/LoggerFactory' ;
15+ import { CancellationError } from '../utils/Delayer' ;
1516
1617const log = LoggerFactory . getLogger ( 'DocumentHandler' ) ;
1718
@@ -36,8 +37,8 @@ export function didOpenHandler(components: ServerComponents): (event: TextDocume
3637
3738 components . cfnLintService . lintDelayed ( content , uri , LintTrigger . OnOpen ) . catch ( ( reason ) => {
3839 // Handle cancellation gracefully - user might have closed/changed the document
39- if ( reason instanceof Error && reason . message . includes ( 'Request cancelled' ) ) {
40- // Do nothing
40+ if ( reason instanceof CancellationError ) {
41+ // Do nothing - cancellation is expected behavior
4142 } else {
4243 log . error ( reason , `Linting error for ${ uri } ` ) ;
4344 }
@@ -105,8 +106,8 @@ export function didChangeHandler(
105106 // Trigger cfn-lint validation
106107 components . cfnLintService . lintDelayed ( content , documentUri , LintTrigger . OnChange , true ) . catch ( ( reason ) => {
107108 // Handle both getTextDocument and linting errors
108- if ( reason instanceof Error && reason . message . includes ( 'Request cancelled' ) ) {
109- // Do nothing
109+ if ( reason instanceof CancellationError ) {
110+ // Do nothing - cancellation is expected behavior
110111 } else {
111112 log . error ( reason , `Error in didChange processing for ${ documentUri } ` ) ;
112113 }
@@ -172,8 +173,8 @@ export function didSaveHandler(components: ServerComponents): (event: TextDocume
172173
173174 // Trigger cfn-lint validation
174175 components . cfnLintService . lintDelayed ( documentContent , documentUri , LintTrigger . OnSave ) . catch ( ( reason ) => {
175- if ( reason instanceof Error && reason . message . includes ( 'Request cancelled' ) ) {
176- // Do nothing
176+ if ( reason instanceof CancellationError ) {
177+ // Do nothing - cancellation is expected behavior
177178 } else {
178179 log . error ( reason , `Linting error for ${ documentUri } ` ) ;
179180 }
0 commit comments