mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 05:53:45 +00:00
detect internal error via error.code
instead of error message
This commit is contained in:
parent
c566136854
commit
0d147b382f
1 changed files with 15 additions and 5 deletions
|
@ -2,15 +2,25 @@ import * as lc from "vscode-languageclient/node";
|
||||||
import * as vscode from "vscode";
|
import * as vscode from "vscode";
|
||||||
|
|
||||||
export class RaLanguageClient extends lc.LanguageClient {
|
export class RaLanguageClient extends lc.LanguageClient {
|
||||||
override error(message: string, data?: any, showNotification?: boolean | "force"): void {
|
override handleFailedRequest<T>(
|
||||||
// ignore `Request TYPE failed.` errors
|
type: lc.MessageSignature,
|
||||||
|
token: vscode.CancellationToken | undefined,
|
||||||
|
error: any,
|
||||||
|
defaultValue: T,
|
||||||
|
showNotification?: boolean | undefined,
|
||||||
|
): T {
|
||||||
const showError = vscode.workspace
|
const showError = vscode.workspace
|
||||||
.getConfiguration("rust-analyzer")
|
.getConfiguration("rust-analyzer")
|
||||||
.get("showRequestFailedErrorNotification");
|
.get("showRequestFailedErrorNotification");
|
||||||
if (!showError && message.startsWith("Request") && message.endsWith("failed.")) {
|
if (
|
||||||
return;
|
!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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue