How to use the vscode-jsonrpc.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 / controller.ts View on Github external
public async handleRequest(request: LspRequest): Promise {
    const file = request.resolvedFilePath;
    if (file) {
      // #todo add test for this
      const lang = await detectLanguage(file.replace('file://', ''));
      if (await this.repoConfigController.isLanguageDisabled(request.documentUri!, lang)) {
        throw new ResponseError(LanguageDisabled, `language disabled for the file`);
      }
      return await this.dispatchRequest(lang, request);
    } else {
      throw new ResponseError(UnknownErrorCode, `can't detect language without a file`);
    }
  }
github reasonml-editor / vscode-reasonml / src / server / session / indexer.ts View on Github external
public async indexSymbols(id: types.TextDocumentIdentifier): Promise> {
    const request = merlin.Query.outline();
    const response = await this.session.merlin.query(request, id);
    if (response.class !== "return") return new rpc.ResponseError(-1, "indexSymbols: failed", undefined);
    for (const item of merlin.Outline.intoCode(response.value, id)) {
      const prefix = item.containerName ? `${item.containerName}.` : "";
      item.name = `${prefix}${item.name}`;
      item.containerName = this.session.environment.relativize(id);
      this.symbols.insert(item);
    }
  };
github elastic / kibana / x-pack / legacy / plugins / code / server / lsp / controller.ts View on Github external
private async findOrCreateHandler(
    languageServer: LanguageServerData,
    request: LspRequest
  ): Promise {
    let handlers: LanguageServerHandlerMap;
    if (languageServer.languageServerHandlers) {
      handlers = languageServer.languageServerHandlers as LanguageServerHandlerMap;
    } else {
      handlers = languageServer.languageServerHandlers = {};
    }
    if (!request.workspacePath) {
      throw new ResponseError(UnknownErrorCode, `no workspace in request?`);
    }
    const realPath = fs.realpathSync(request.workspacePath);
    let handler = handlers[realPath];
    if (handler) {
      return handler;
    } else {
      const maxWorkspace = languageServer.maxWorkspace;
      const handlerArray = Object.entries(handlers);
      if (handlerArray.length < maxWorkspace) {
        handler = languageServer.launcher.launch(
          languageServer.builtinWorkspaceFolders,
          maxWorkspace
        );
        handlers[realPath] = handler;
        return handler;
      } else {
github eclipse-theia / theia / packages / core / src / common / messaging / proxy-factory.ts View on Github external
protected serializeError(e: any): any {
        if (ApplicationError.is(e)) {
            return new ResponseError(e.code, '',
                Object.assign({ kind: 'application' }, e.toJson())
            );
        }
        return e;
    }
    protected deserializeError(capturedError: Error, e: any): any {