Skip to content

Commit 0d147b3

Browse files
committed
detect internal error via error.code instead of error message
1 parent c566136 commit 0d147b3

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

editors/code/src/lang_client.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@ import * as lc from "vscode-languageclient/node";
22
import * as vscode from "vscode";
33

44
export class RaLanguageClient extends lc.LanguageClient {
5-
override error(message: string, data?: any, showNotification?: boolean | "force"): void {
6-
// ignore `Request TYPE failed.` errors
5+
override handleFailedRequest<T>(
6+
type: lc.MessageSignature,
7+
token: vscode.CancellationToken | undefined,
8+
error: any,
9+
defaultValue: T,
10+
showNotification?: boolean | undefined,
11+
): T {
712
const showError = vscode.workspace
813
.getConfiguration("rust-analyzer")
914
.get("showRequestFailedErrorNotification");
10-
if (!showError && message.startsWith("Request") && message.endsWith("failed.")) {
11-
return;
15+
if (
16+
!showError &&
17+
error instanceof lc.ResponseError &&
18+
error.code === lc.ErrorCodes.InternalError
19+
) {
20+
// Don't show notification for internal errors, these are emitted by r-a when a request fails.
21+
showNotification = false;
1222
}
1323

14-
super.error(message, data, showNotification);
24+
return super.handleFailedRequest(type, token, error, defaultValue, showNotification);
1525
}
1626
}

0 commit comments

Comments
 (0)