[PATCH] D66211: [clangd][vscode] Surface the error when applying tweaks fails
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 14 04:17:33 PDT 2019
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.
The current behavior for a failed request is just to log it in the
output panel. When applyTweak fails for whatever reason, users usually don't get
informed (unless they open the output panel and dig the log).
this patch is to surface these errors by prompting up a message diag.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D66211
Files:
clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===================================================================
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ 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(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66211.215079.patch
Type: text/x-patch
Size: 1553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190814/3b28f13c/attachment.bin>
More information about the cfe-commits
mailing list