Permalink
Browse files

Better exception when trying to access results for failed multi-searc…

…h query - fixes #1032
  • Loading branch information...
ankane committed Nov 29, 2017
1 parent fc62c49 commit 70361fb2868ed9709c6a140322b22297487214ac
Showing with 12 additions and 5 deletions.
  1. +1 −0 CHANGELOG.md
  2. +5 −1 lib/searchkick/results.rb
  3. +6 −4 test/multi_search_test.rb
View
@@ -1,5 +1,6 @@
## 2.4.1 [unreleased]
- Better exception when trying to access results for failed multi-search query
- Added support for `faraday_middleware-aws-sigv4`
- Added `credentials` option to `aws_credentials`
@@ -187,7 +187,11 @@ def out_of_range?
end
def hits
@response["hits"]["hits"]
if error
raise Searchkick::Error, "Query error - use the error method to view it"
else
@response["hits"]["hits"]
end
end
def misspellings?
View
@@ -34,9 +34,11 @@ def test_misspellings_below_unmet_retry
assert_equal ["abc", "abd"], products.map(&:name)
end
# https://github.com/ankane/searchkick/issues/1032
def test_no_records
products = Product.search("*", order: {created_at: :asc}, execute: false)
assert Searchkick.multi_search([products])[0].results
def test_error
products = Product.search("*", order: {bad_column: :asc}, execute: false)
Searchkick.multi_search([products])
assert products.error
error = assert_raises(Searchkick::Error) { products.results }
assert_equal error.message, "Query error - use the error method to view it"
end
end

0 comments on commit 70361fb

Please sign in to comment.