How to use the vscode-jsonrpc/lib/messages.ResponseError function in vscode-jsonrpc

To help you get started, we’ve selected a few vscode-jsonrpc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elastic / kibana / x-pack / legacy / plugins / code / server / lsp / request_expander.ts View on Github external
Initializing = 'Initializing',
  Initialized = 'Initialized',
}

interface Workspace {
  lastAccess: number;
  status: WorkspaceStatus;
  initPromise?: Cancelable;
}

export interface InitializeOptions {
  clientCapabilities?: ClientCapabilities;
  initialOptions?: object;
}

export const WorkspaceUnloadedError = new ResponseError(RequestCancelled, 'Workspace unloaded');

export class RequestExpander implements ILanguageServerHandler {
  public lastAccess: number = 0;
  private proxy: LanguageServerProxy;
  // a map for workspacePath -> Workspace
  private workspaces: Map = new Map();
  private readonly workspaceRoot: string;
  private exited = false;

  constructor(
    proxy: LanguageServerProxy,
    readonly builtinWorkspace: boolean,
    readonly maxWorkspace: number,
    readonly serverOptions: ServerOptions,
    readonly initialOptions: InitializeOptions,
    readonly log: Logger
github elastic / kibana / x-pack / legacy / plugins / code / server / lsp / proxy.ts View on Github external
public connected(): Promise {
    if (this.closed) {
      return Promise.reject(new ResponseError(RequestCancelled, 'Server closed'));
    } else if (this.error) {
      return Promise.reject(new ResponseError(InternalError, 'Server error', this.error));
    } else if (this.clientConnection) {
      return Promise.resolve(this.clientConnection);
    } else {
      return new Promise((resolve, reject) => {
        this.eventEmitter.on('err', error =>
          reject(new ResponseError(InternalError, 'Server error', error))
        );
        this.eventEmitter.on('exit', () =>
          reject(new ResponseError(RequestCancelled, 'Server closed'))
        );
        this.eventEmitter.on('connect', () => resolve(this.clientConnection!));
      });
    }
  }
github elastic / kibana / x-pack / legacy / plugins / code / server / lsp / proxy.ts View on Github external
public connected(): Promise {
    if (this.closed) {
      return Promise.reject(new ResponseError(RequestCancelled, 'Server closed'));
    } else if (this.error) {
      return Promise.reject(new ResponseError(InternalError, 'Server error', this.error));
    } else if (this.clientConnection) {
      return Promise.resolve(this.clientConnection);
    } else {
      return new Promise((resolve, reject) => {
        this.eventEmitter.on('err', error =>
          reject(new ResponseError(InternalError, 'Server error', error))
        );
        this.eventEmitter.on('exit', () =>
          reject(new ResponseError(RequestCancelled, 'Server closed'))
        );
        this.eventEmitter.on('connect', () => resolve(this.clientConnection!));
      });
    }
  }
github elastic / kibana / x-pack / legacy / plugins / code / server / lsp / proxy.ts View on Github external
this.eventEmitter.on('exit', () =>
          reject(new ResponseError(RequestCancelled, 'Server closed'))
        );
github elastic / kibana / x-pack / plugins / code / common / lsp_client.ts View on Github external
signal?: AbortSignal
  ): Promise {
    try {
      const response = await kfetch({
        pathname: `${this.baseUri}/${method}`,
        method: 'POST',
        body: JSON.stringify(params),
        signal,
      });
      return response as ResponseMessage;
    } catch (e) {
      let error = e;
      if (error.body && error.body.error) {
        error = error.body.error;
      }
      throw new ResponseError(error.code, error.message, error.data);
    }
  }
}
github elastic / kibana / x-pack / legacy / plugins / code / server / lsp / proxy.ts View on Github external
this.eventEmitter.on('err', error =>
          reject(new ResponseError(InternalError, 'Server error', error))
        );