MCPcopy Index your code
hub / github.com/microsoft/vscode-languageserver-node / DefaultErrorHandler

Class DefaultErrorHandler

client/src/client.ts:274–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274class DefaultErrorHandler implements ErrorHandler {
275
276 private restarts: number[];
277
278 constructor(private name: string) {
279 this.restarts = [];
280 }
281
282 public error(_error: Error, _message: Message, count: number): ErrorAction {
283 if (count && count <= 3) {
284 return ErrorAction.Continue;
285 }
286 return ErrorAction.Shutdown;
287 }
288 public closed(): CloseAction {
289 this.restarts.push(Date.now());
290 if (this.restarts.length < 5) {
291 return CloseAction.Restart;
292 } else {
293 let diff = this.restarts[this.restarts.length - 1] - this.restarts[0];
294 if (diff <= 3 * 60 * 1000) {
295 Window.showErrorMessage(`The ${this.name} server crashed 5 times in the last 3 minutes. The server will not be restarted.`);
296 return CloseAction.DoNotRestart;
297 } else {
298 this.restarts.shift();
299 return CloseAction.Restart;
300 }
301 }
302 }
303}
304
305export interface InitializationFailedHandler {
306 (error: ResponseError<InitializeError> | Error | any): boolean;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected