lib/elasticsearch/api/actions/ping.rb in elasticsearch-api-8.12.2 vs lib/elasticsearch/api/actions/ping.rb in elasticsearch-api-8.13.0

- old
+ new

@@ -23,31 +23,29 @@ module Actions # Returns whether the cluster is running. # # @option arguments [Hash] :headers Custom HTTP headers # - # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.12/index.html + # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.13/index.html # def ping(arguments = {}) - request_opts = { endpoint: arguments[:endpoint] || "ping" } + request_opts = { endpoint: arguments[:endpoint] || 'ping' } arguments = arguments.clone headers = arguments.delete(:headers) || {} body = nil method = Elasticsearch::API::HTTP_HEAD - path = "" + path = '' params = {} begin - perform_request(method, path, params, body, headers, request_opts).status == 200 ? true : false + perform_request(method, path, params, body, headers, request_opts).status == 200 rescue Exception => e - if e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not *Found|404|ConnectionFailed/i - false - else - raise e - end + raise e unless e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not *Found|404|ConnectionFailed/i + + false end end end end end