@@ -13,7 +13,7 @@ import {
1313 CloseHandlerResult ,
1414} from 'vscode-languageclient/node'
1515import { CloseAction , ErrorAction , Message } from 'vscode-languageclient/node'
16- import { formatMessage , toString } from './utils'
16+ import { toString } from './utils'
1717import globals from '../../shared/extensionGlobals'
1818import { getServiceEnvVarConfig } from '../../shared/vscode/env'
1919import { DevSettings } from '../../shared/settings'
@@ -167,21 +167,30 @@ async function startClient(context: ExtensionContext) {
167167 } ,
168168 errorHandler : {
169169 error : ( error : Error , message : Message | undefined , count : number | undefined ) : ErrorHandlerResult => {
170- void window . showErrorMessage ( formatMessage ( `Error count = ${ count } ): ${ toString ( message ) } `) )
170+ getLogger ( ) . warn ( `CloudFormation LSP error (count: ${ count } ): ${ toString ( message ) } `)
171171 return { action : ErrorAction . Continue }
172172 } ,
173173 closed : ( ) : CloseHandlerResult => {
174- void window . showWarningMessage ( formatMessage ( `Server connection closed` ) )
175- return { action : CloseAction . DoNotRestart }
174+ getLogger ( ) . info ( 'CloudFormation LSP connection closed' )
175+ return { action : CloseAction . DoNotRestart , message : '' }
176176 } ,
177177 } ,
178+ initializationFailedHandler : ( ) => {
179+ getLogger ( ) . error ( 'CloudFormation LSP initialization failed' )
180+ return false
181+ } ,
178182 }
179183
180184 client = new LanguageClient ( ExtensionId , ExtensionName , serverOptions , clientOptions )
181185
182186 const stacksManager = new StacksManager ( client )
183187
184- await client . start ( )
188+ try {
189+ await client . start ( )
190+ } catch ( error ) {
191+ getLogger ( ) . error ( `CloudFormation LSP failed to start: ${ toString ( error ) } ` )
192+ return
193+ }
185194
186195 const documentManager = new DocumentManager ( client )
187196 const resourceSelector = new ResourceSelector ( client )
@@ -322,9 +331,7 @@ export async function activate(context: ExtensionContext) {
322331 try {
323332 await restartClient ( context )
324333 } catch ( error ) {
325- void window . showErrorMessage (
326- formatMessage ( `Failed to restart CloudFormation language server: ${ toString ( error ) } ` )
327- )
334+ getLogger ( ) . error ( `Failed to restart CloudFormation language server: ${ toString ( error ) } ` )
328335 }
329336 } )
330337 )
0 commit comments