How to use the @elastic/elasticsearch.errors function in @elastic/elasticsearch

To help you get started, we’ve selected a few @elastic/elasticsearch 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 kuzzleio / kuzzle / lib / util / esWrapper.js View on Github external
formatESError(error) {
    if (error instanceof KuzzleError) {
      return error;
    }

    if (error instanceof es.errors.NoLivingConnectionsError) {
      errorsManager.throw('not_connected');
    }
    const message = _.get(error, 'meta.body.error.reason', error.message);

    // Try to match a known elasticsearch error
    for (const mapping of errorMessagesMapping) {
      const matches = message.match(mapping.regex);

      if (matches) {
        return errorsManager.get(
          mapping.subcode,
          ...mapping.getPlaceholders(matches));
      }
    }

    // Try to match using error codes

@elastic/elasticsearch

The official Elasticsearch client for Node.js

Apache-2.0
Latest version published 17 days ago

Package Health Score

98 / 100
Full package analysis

Popular @elastic/elasticsearch functions