Skip to content

Commit 8dfd393

Browse files
committed
src/commands: catch errors when starting language server
Added a catch block to the start language server logic to ensure the rest of the extension activation completes. Change-Id: I1664da130a981ef8034d1f0e8723b72a4be2d594 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/413424 Run-TryBot: Jamal Carvalho <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
1 parent 16009b2 commit 8dfd393

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/commands/startLanguageServer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ export const startLanguageServer: CommandFactory = (ctx, goCtx) => {
9595
goCtx.serverInfo = toServerInfo(goCtx.languageClient.initializeResult);
9696
updateStatus(goCtx, goConfig, true);
9797
console.log(`Server: ${JSON.stringify(goCtx.serverInfo, null, 2)}`);
98+
} catch (e) {
99+
const msg = `Error starting language server: ${e}`;
100+
console.log(msg);
101+
goCtx.serverOutputChannel?.append(msg);
98102
} finally {
99103
goCtx.latestConfig = cfg;
100104
unlock();

src/goMain.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<ExtensionA
102102
offerToInstallLatestGoVersion();
103103
offerToInstallTools();
104104

105+
const registerCommand = commands.createRegisterCommand(ctx, goCtx);
106+
registerCommand('go.languageserver.restart', commands.startLanguageServer);
107+
105108
await commands.startLanguageServer(ctx, goCtx)(RestartReason.ACTIVATION);
106109

107110
initCoverageDecorators(ctx);
108111

109-
const registerCommand = commands.createRegisterCommand(ctx, goCtx);
110-
111-
registerCommand('go.languageserver.restart', commands.startLanguageServer);
112112
registerCommand('go.builds.run', commands.runBuilds);
113113

114114
const activeDoc = vscode.window.activeTextEditor?.document;

0 commit comments

Comments
 (0)