Skip to content

Commit d2445bc

Browse files
authored
Handle request error code RoslynLspNonFatalRequestFailure (#8935)
1 parent 1232acc commit d2445bc

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/lsptoolshost/server/roslynLanguageClient.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { LanguageClientOptions, ServerOptions } from 'vscode-languageclient';
99
import CompositeDisposable from '../../compositeDisposable';
1010
import { IDisposable } from '../../disposable';
1111
import { languageServerOptions } from '../../shared/options';
12+
import { RoslynLspErrorCodes } from './roslynProtocol';
1213

1314
/**
1415
* Implementation of the base LanguageClient type that allows for additional items to be disposed of
@@ -41,6 +42,10 @@ export class RoslynLanguageClient extends LanguageClient {
4142
defaultValue: T,
4243
showNotification?: boolean
4344
) {
45+
if (error.code == RoslynLspErrorCodes.nonFatalRequestFailure) {
46+
return super.handleFailedRequest(type, token, error, defaultValue, false);
47+
}
48+
4449
// Temporarily allow LSP error toasts to be suppressed if configured.
4550
// There are a few architectural issues preventing us from solving some of the underlying problems,
4651
// for example Razor cohosting to fix text mismatch issues and unification of serialization libraries

src/lsptoolshost/server/roslynProtocol.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,15 @@ export namespace RefreshSourceGeneratedDocumentNotification {
370370
export const messageDirection: MessageDirection = MessageDirection.serverToClient;
371371
export const type = new NotificationType(method);
372372
}
373+
374+
export namespace RoslynLspErrorCodes {
375+
/**
376+
* Indicates that the server could not process the request, but that the failure shouldn't be surfaced to the user.
377+
* (It's expected that the failure is still logged, however.)
378+
*
379+
* This is only meant to be used under conditions where we can't fulfill the request, but we think that the failure
380+
* is unlikely to be significant to the user (i.e. surface as an actual editor feature failing to function properly.)
381+
* For example, if pull diagnostics are requested for a virtual document that was already closed.
382+
*/
383+
export const nonFatalRequestFailure = -30099;
384+
}

0 commit comments

Comments
 (0)