Skip to content

Commit 0149954

Browse files
mlangenbergkarmi
authored andcommitted
[CLIENT] Fixed, that ServerError inherits from Transport::Error
Allow rescuing raised Errors::NotFound or Errors::ServerError by rescue Transport::Error. Behavior is now in line with documentation: “The highest-level exception is {Elasticsearch::Transport::Transport::Error} and will be raised for any generic client or server errors.” Closes #100
1 parent 8107109 commit 0149954

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

elasticsearch-transport/lib/elasticsearch/transport/transport/errors.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class SnifferTimeoutError < Timeout::Error; end
1212

1313
# Elasticsearch server error (HTTP status 5xx)
1414
#
15-
class ServerError < StandardError; end
15+
class ServerError < Error; end
1616

1717
module Errors; end
1818

elasticsearch-transport/test/unit/transport_base_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,4 +452,9 @@ def initialize(*); end
452452
end
453453
end
454454

455+
context "errors" do
456+
should "raise highest-level Error exception for any ServerError" do
457+
assert_kind_of Elasticsearch::Transport::Transport::Error, Elasticsearch::Transport::Transport::ServerError.new
458+
end
459+
end
455460
end

0 commit comments

Comments
 (0)