Sha256: 9097ea3ce8b4dc156375f039d327e42a18f2f3c386d7fb065b87fe09a3955166

Contents?: true

Size: 851 Bytes

Versions: 1

Compression:

Stored size: 851 Bytes

Contents

# frozen_string_literal: true

module Esse
  class ClientProxy
    require_relative './client_proxy/search'

    extend Forwardable

    def_delegators :@cluster, :client

    attr_reader :cluster

    def initialize(cluster)
      @cluster = cluster
    end

    # Elasticsearch::Transport was renamed to Elastic::Transport in 8.0
    # This lib should support both versions that's why we are wrapping up the transport
    # errors to local errors.
    def coerce_exception
      yield
    rescue => exception
      name = Hstring.new(exception.class.name)
      if /^(Elasticsearch|Elastic|OpenSearch)?::Transport::Transport::Errors/.match?(name.value) && \
          (exception_class = Esse::Backend::ERRORS[name.demodulize.value])
        raise exception_class.new(exception.message)
      else
        raise exception
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
esse-0.2.2 lib/esse/client_proxy.rb