about summary refs log tree commit diff
path: root/editors/code
diff options
context:
space:
mode:
authorjprochazk <1665677+jprochazk@users.noreply.github.com>2023-11-15 12:36:08 +0100
committerjprochazk <1665677+jprochazk@users.noreply.github.com>2023-11-15 12:36:08 +0100
commit0d147b382f46d9f19145d03295519ca4558858af (patch)
treec1814d5cc82ad279b13d59695380d3e2d1afba20 /editors/code
parentc566136854734ff32ddaaed107c74759a3a3862f (diff)
downloadrust-0d147b382f46d9f19145d03295519ca4558858af.tar.gz
rust-0d147b382f46d9f19145d03295519ca4558858af.zip
detect internal error via `error.code` instead of error message
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/src/lang_client.ts20
1 files changed, 15 insertions, 5 deletions
diff --git a/editors/code/src/lang_client.ts b/editors/code/src/lang_client.ts
index e28330e6dba..09d64efc048 100644
--- a/editors/code/src/lang_client.ts
+++ b/editors/code/src/lang_client.ts
@@ -2,15 +2,25 @@ import * as lc from "vscode-languageclient/node";
 import * as vscode from "vscode";
 
 export class RaLanguageClient extends lc.LanguageClient {
-    override error(message: string, data?: any, showNotification?: boolean | "force"): void {
-        // ignore `Request TYPE failed.` errors
+    override handleFailedRequest<T>(
+        type: lc.MessageSignature,
+        token: vscode.CancellationToken | undefined,
+        error: any,
+        defaultValue: T,
+        showNotification?: boolean | undefined,
+    ): T {
         const showError = vscode.workspace
             .getConfiguration("rust-analyzer")
             .get("showRequestFailedErrorNotification");
-        if (!showError && message.startsWith("Request") && message.endsWith("failed.")) {
-            return;
+        if (
+            !showError &&
+            error instanceof lc.ResponseError &&
+            error.code === lc.ErrorCodes.InternalError
+        ) {
+            // Don't show notification for internal errors, these are emitted by r-a when a request fails.
+            showNotification = false;
         }
 
-        super.error(message, data, showNotification);
+        return super.handleFailedRequest(type, token, error, defaultValue, showNotification);
     }
 }