diff --git a/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts b/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts --- a/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts +++ b/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts @@ -91,6 +91,26 @@ const clangdClient = new vscodelc.LanguageClient( 'Clang Language Server', serverOptions, clientOptions); + + // We override the default implementation for failed requests. The default + // behavior is just to log failures in the output panel, however output panel + // is designed for extension debugging purpose, normal users will not open it, + // thus when the failure occurs, normal users doesn't know that. + // + // For user-interactive operations (e.g. applyFixIt, applyTweaks), we will prompt + // up the failure to users. + clangdClient.logFailedRequest = + (rpcReply: vscodelc.RPCMessageType, error: any) => { + if (error instanceof vscodelc.ResponseError && + rpcReply.method === "workspace/executeCommand") + vscode.window.showErrorMessage(error.message); + + // Keep the default behavior. + if (error instanceof vscodelc.ResponseError && + error.code === vscodelc.ErrorCodes.RequestCancelled) + return; + clangdClient.error(`Request ${rpcReply.method} failed.`, error); + }; console.log('Clang Language Server is now active!'); context.subscriptions.push(clangdClient.start()); context.subscriptions.push(vscode.commands.registerCommand(