Sha256: 5001adc9f818f95fa85f2ce49003cb25327b8626c2934329498e405f3c552e8f
Contents?: true
Size: 1.45 KB
Versions: 12
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true module Esse class Transport require_relative './transport/aliases' require_relative './transport/health' require_relative './transport/indices' require_relative './transport/search' require_relative './transport/documents' extend Forwardable def_delegators :@cluster, :client, :throw_error_when_readonly! 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. # # We are not only coercing exceptions but also the response body. Elasticsearch-ruby >= 8.0 returns # the response wrapped in a Elasticsearch::API::Response::Response object. We are unwrapping it # to keep the same interface. But we may want to coerce it to some internal object in the future. def coerce_exception resp = yield if resp.class.name.start_with?('Elasticsearch::API::Response') resp = resp.body end resp rescue => exception name = Hstring.new(exception.class.name) if /^(Elasticsearch|Elastic|OpenSearch)?::Transport::Transport::Errors/.match?(name.value) && \ (exception_class = Esse::Transport::ERRORS[name.demodulize.value]) raise exception_class.new(exception.message) else raise exception end end end end
Version data entries
12 entries across 12 versions & 1 rubygems