Skip to content

Commit

Permalink
[API] Changed more APIs to use the unified NotFound error handling
Browse files Browse the repository at this point in the history
Related: 4e2a3d3
Related: #126
  • Loading branch information
karmi committed May 19, 2015
1 parent 4e2a3d3 commit 5daba08
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 41 deletions.
8 changes: 2 additions & 6 deletions elasticsearch-api/lib/elasticsearch/api/actions/delete.rb
Expand Up @@ -51,12 +51,8 @@ def delete(arguments={})
params = Utils.__validate_and_extract_params arguments, valid_params
body = nil

perform_request(method, path, params, body).body

rescue Exception => e
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
else raise(e)
Utils.__rescue_from_not_found do
perform_request(method, path, params, body).body
end
end
end
Expand Down
8 changes: 2 additions & 6 deletions elasticsearch-api/lib/elasticsearch/api/actions/get.rb
Expand Up @@ -61,12 +61,8 @@ def get(arguments={})

params[:fields] = Utils.__listify(params[:fields]) if params[:fields]

perform_request(method, path, params, body).body

rescue Exception => e
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
else raise(e)
Utils.__rescue_from_not_found do
perform_request(method, path, params, body).body
end
end
end
Expand Down
8 changes: 2 additions & 6 deletions elasticsearch-api/lib/elasticsearch/api/actions/get_source.rb
Expand Up @@ -58,12 +58,8 @@ def get_source(arguments={})

params[:fields] = Utils.__listify(params[:fields]) if params[:fields]

perform_request(method, path, params, body).body

rescue Exception => e
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
else raise(e)
Utils.__rescue_from_not_found do
perform_request(method, path, params, body).body
end
end
end
Expand Down
Expand Up @@ -16,11 +16,8 @@ def get_template(arguments={})
params = {}
body = arguments[:body]

perform_request(method, path, params, body).body
rescue Exception => e
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
else raise(e)
Utils.__rescue_from_not_found do
perform_request(method, path, params, body).body
end
end
end
Expand Down
Expand Up @@ -38,12 +38,8 @@ def delete(arguments={})
params = Utils.__validate_and_extract_params arguments, valid_params
body = nil

perform_request(method, path, params, body).body

rescue Exception => e
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
else raise(e)
Utils.__rescue_from_not_found do
perform_request(method, path, params, body).body
end
end
end
Expand Down
Expand Up @@ -28,12 +28,8 @@ def delete_template(arguments={})
params = Utils.__validate_and_extract_params arguments, valid_params
body = nil

perform_request(method, path, params, body).body

rescue Exception => e
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
else raise(e)
Utils.__rescue_from_not_found do
perform_request(method, path, params, body).body
end
end
end
Expand Down
8 changes: 2 additions & 6 deletions elasticsearch-api/lib/elasticsearch/api/actions/update.rb
Expand Up @@ -94,12 +94,8 @@ def update(arguments={})

params[:fields] = Utils.__listify(params[:fields]) if params[:fields]

perform_request(method, path, params, body).body

rescue Exception => e
# NOTE: Use exception name, not full class in Elasticsearch::Client to allow client plugability
if Array(arguments[:ignore]).include?(404) && e.class.to_s =~ /NotFound/; false
else raise(e)
Utils.__rescue_from_not_found do
perform_request(method, path, params, body).body
end
end
end
Expand Down

0 comments on commit 5daba08

Please sign in to comment.