diff --git a/lib/elastomer_client/client.rb b/lib/elastomer_client/client.rb index 51519366..fb92ac30 100644 --- a/lib/elastomer_client/client.rb +++ b/lib/elastomer_client/client.rb @@ -270,7 +270,7 @@ def request(method, path, params) handle_errors response # wrap Faraday errors with appropriate ElastomerClient::Client error classes - rescue Faraday::Error::ClientError => boom + rescue Faraday::ClientError, Faraday::ServerError => boom error = wrap_faraday_error(boom, method, path) raise error rescue OpaqueIdError => boom diff --git a/lib/elastomer_client/client/errors.rb b/lib/elastomer_client/client/errors.rb index f90638ef..3012a2ab 100644 --- a/lib/elastomer_client/client/errors.rb +++ b/lib/elastomer_client/client/errors.rb @@ -97,17 +97,6 @@ def fatal ConnectionFailed.fatal = false RejectedExecutionError.fatal = false - # Define an ElastomerClient::Client exception class on the fly for - # Faraday exception classes that we don't specifically wrap. - Faraday::Error.constants.each do |error_name| - next if ::ElastomerClient::Client.const_get(error_name) rescue nil - - error_class = Faraday::Error.const_get(error_name) - next unless error_class < Faraday::Error::ClientError - - ::ElastomerClient::Client.const_set(error_name, Class.new(Error)) - end - # Exception for operations that are unsupported with the version of # Elasticsearch being used. IncompatibleVersionException = Class.new Error diff --git a/lib/elastomer_client/middleware/parse_json.rb b/lib/elastomer_client/middleware/parse_json.rb index dee05a70..845395f3 100644 --- a/lib/elastomer_client/middleware/parse_json.rb +++ b/lib/elastomer_client/middleware/parse_json.rb @@ -20,7 +20,7 @@ def call(environment) def parse(body) MultiJson.load(body) if body.respond_to?(:to_str) && !body.strip.empty? rescue StandardError, SyntaxError => e - raise Faraday::Error::ParsingError, e + raise Faraday::ParsingError, e end def process_response?(env) diff --git a/test/client/errors_test.rb b/test/client/errors_test.rb index 224dc33f..af0309e1 100644 --- a/test/client/errors_test.rb +++ b/test/client/errors_test.rb @@ -47,7 +47,7 @@ end it "is instantiated from another exception" do - err = Faraday::Error::ConnectionFailed.new "could not connect to host" + err = Faraday::ConnectionFailed.new "could not connect to host" err.set_backtrace %w[one two three four] err = ElastomerClient::Client::Error.new(err, "POST", "/index/doc") diff --git a/test/middleware/parse_json_test.rb b/test/middleware/parse_json_test.rb index 3acbf413..84bb6452 100644 --- a/test/middleware/parse_json_test.rb +++ b/test/middleware/parse_json_test.rb @@ -49,14 +49,14 @@ def process(body, content_type = nil) end it "chokes on invalid json" do - assert_raises(Faraday::Error::ParsingError) { process "{!" } - assert_raises(Faraday::Error::ParsingError) { process "invalid" } + assert_raises(Faraday::ParsingError) { process "{!" } + assert_raises(Faraday::ParsingError) { process "invalid" } # surprisingly these are all valid according to MultiJson # - # assert_raises(Faraday::Error::ParsingError) { process '"a"' } - # assert_raises(Faraday::Error::ParsingError) { process 'true' } - # assert_raises(Faraday::Error::ParsingError) { process 'null' } - # assert_raises(Faraday::Error::ParsingError) { process '1' } + # assert_raises(Faraday::ParsingError) { process '"a"' } + # assert_raises(Faraday::ParsingError) { process 'true' } + # assert_raises(Faraday::ParsingError) { process 'null' } + # assert_raises(Faraday::ParsingError) { process '1' } end end diff --git a/test/notifications_test.rb b/test/notifications_test.rb index c9b70920..6b5fec96 100644 --- a/test/notifications_test.rb +++ b/test/notifications_test.rb @@ -20,7 +20,7 @@ end it "instruments timeouts" do - $client.stub :connection, lambda { raise Faraday::Error::TimeoutError } do + $client.stub :connection, lambda { raise Faraday::TimeoutError } do assert_raises(ElastomerClient::Client::TimeoutError) { $client.info } event = @events.detect { |e| e.payload[:action] == "cluster.info" } exception = event.payload[:exception]