@@ -54,6 +54,10 @@ export class CfnLintService implements SettingsConfigurable, Closeable {
5454
5555 @Telemetry ( ) private readonly telemetry ! : ScopedTelemetry ;
5656
57+ private logError ( operation : string , error : unknown ) : void {
58+ this . log . error ( `Error ${ operation } : ${ extractErrorMessage ( error ) } ` ) ;
59+ }
60+
5761 // Request queue for handling requests during initialization
5862 private readonly requestQueue = new Map <
5963 string ,
@@ -147,7 +151,7 @@ export class CfnLintService implements SettingsConfigurable, Closeable {
147151 await this . workerManager . mountFolder ( fsDir , mountDir ) ;
148152 this . telemetry . count ( 'mount.success' , 1 , { unit : '1' } ) ;
149153 } catch ( error ) {
150- this . log . error ( `Error mounting folder: ${ extractErrorMessage ( error ) } ` ) ;
154+ this . logError ( ' mounting folder' , error ) ;
151155 this . telemetry . count ( 'mount.fault' , 1 , { unit : '1' } ) ;
152156 throw error ; // Re-throw to notify caller
153157 }
@@ -205,7 +209,7 @@ export class CfnLintService implements SettingsConfigurable, Closeable {
205209 this . diagnosticCoordinator
206210 . publishDiagnostics ( CfnLintService . CFN_LINT_SOURCE , uri , diagnostics )
207211 . catch ( ( reason ) => {
208- this . log . error ( `Error publishing diagnostics: ${ extractErrorMessage ( reason ) } ` ) ;
212+ this . logError ( ' publishing diagnostics' , reason ) ;
209213 } ) ;
210214 }
211215
@@ -255,13 +259,13 @@ export class CfnLintService implements SettingsConfigurable, Closeable {
255259 await this . diagnosticCoordinator
256260 . publishDiagnostics ( CfnLintService . CFN_LINT_SOURCE , payload . uri , payload . diagnostics )
257261 . catch ( ( reason ) => {
258- this . log . error ( `Error publishing diagnostics: ${ extractErrorMessage ( reason ) } ` ) ;
262+ this . logError ( ' publishing diagnostics' , reason ) ;
259263 } ) ;
260264 }
261265 }
262266 } catch ( error ) {
263267 const errorMessage = extractErrorMessage ( error ) ;
264- this . log . error ( `Error linting ${ fileType } by string: ${ errorMessage } ` ) ;
268+ this . logError ( ` linting ${ fileType } by string` , error ) ;
265269 this . publishErrorDiagnostics ( uri , errorMessage ) ;
266270 }
267271 }
@@ -279,7 +283,7 @@ export class CfnLintService implements SettingsConfigurable, Closeable {
279283 ? deploymentFile [ 'template-file-path' ]
280284 : undefined ;
281285 } catch ( error ) {
282- this . log . error ( `Error parsing deployment file: ${ extractErrorMessage ( error ) } ` ) ;
286+ this . logError ( ' parsing deployment file' , error ) ;
283287 return undefined ;
284288 }
285289 }
@@ -328,13 +332,13 @@ export class CfnLintService implements SettingsConfigurable, Closeable {
328332 await this . diagnosticCoordinator
329333 . publishDiagnostics ( CfnLintService . CFN_LINT_SOURCE , payload . uri , payload . diagnostics )
330334 . catch ( ( reason ) => {
331- this . log . error ( `Error publishing diagnostics: ${ extractErrorMessage ( reason ) } ` ) ;
335+ this . logError ( ' publishing diagnostics' , reason ) ;
332336 } ) ;
333337 }
334338 }
335339 } catch ( error ) {
336340 const errorMessage = extractErrorMessage ( error ) ;
337- this . log . error ( `Error linting ${ fileType } by file: ${ errorMessage } ` ) ;
341+ this . logError ( ` linting ${ fileType } by file` , error ) ;
338342 this . publishErrorDiagnostics ( uri , errorMessage ) ;
339343 }
340344 }
@@ -375,7 +379,7 @@ export class CfnLintService implements SettingsConfigurable, Closeable {
375379 await this . waitForInitialization ( ) ;
376380 } catch ( error ) {
377381 this . telemetry . count ( 'lint.uninitialized' , 1 , { unit : '1' } ) ;
378- this . log . error ( `Failed to wait for CfnLintService initialization: ${ extractErrorMessage ( error ) } ` ) ;
382+ this . logError ( 'waiting for CfnLintService initialization' , error ) ;
379383 throw error ;
380384 }
381385
@@ -391,7 +395,10 @@ export class CfnLintService implements SettingsConfigurable, Closeable {
391395 if ( fileType === CloudFormationFileType . GitSyncDeployment ) {
392396 this . telemetry . count ( `lint.file.${ CloudFormationFileType . GitSyncDeployment } ` , 1 , { unit : '1' } ) ;
393397
394- this . log . error ( `GitSync deployment file ${ uri } cannot be processed outside of a workspace context` ) ;
398+ this . logError (
399+ `processing GitSync deployment file ${ uri } ` ,
400+ new Error ( 'cannot be processed outside of a workspace context' ) ,
401+ ) ;
395402 this . publishDiagnostics ( uri , [ ] ) ;
396403 return ;
397404 }
@@ -452,7 +459,7 @@ export class CfnLintService implements SettingsConfigurable, Closeable {
452459 }
453460 this . processQueuedRequests ( ) ;
454461 } catch ( error ) {
455- this . log . error ( `Initialization failed: ${ extractErrorMessage ( error ) } ` ) ;
462+ this . logError ( 'during initialization' , error ) ;
456463 // Re-throw to let callers know initialization failed
457464 throw error ;
458465 }
@@ -505,7 +512,7 @@ export class CfnLintService implements SettingsConfigurable, Closeable {
505512 request . resolve ( ) ;
506513 } )
507514 . catch ( ( reason : unknown ) => {
508- this . log . error ( `Error processing queued request for ${ uri } : ${ extractErrorMessage ( reason ) } ` ) ;
515+ this . logError ( ` processing queued request for ${ uri } ` , reason ) ;
509516 request . reject ( reason ) ;
510517 } ) ;
511518 }
@@ -575,7 +582,7 @@ export class CfnLintService implements SettingsConfigurable, Closeable {
575582
576583 // Trigger initialization if needed (but don't await it here)
577584 this . ensureInitialized ( ) . catch ( ( error ) => {
578- this . log . error ( `Failed to ensure initialization: ${ extractErrorMessage ( error ) } ` ) ;
585+ this . logError ( 'ensuring initialization' , error ) ;
579586 } ) ;
580587 } ) ;
581588 }
0 commit comments