Skip to content

Commit

Permalink
detect internal error via error.code instead of error message
Browse files Browse the repository at this point in the history
  • Loading branch information
jprochazk committed Nov 15, 2023
1 parent c566136 commit 0d147b3
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions editors/code/src/lang_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 0d147b3

Please sign in to comment.