Commit 025caf833bbbfd81247b82be9af11486aee8b670
1 parent
0eff3131
Exists in
master
and in
2 other branches
DRY unsupported version error [skip ci]
Showing
3 changed files
with
8 additions
and
4 deletions
Show diff stats
lib/searchkick.rb
... | ... | @@ -33,7 +33,11 @@ module Searchkick |
33 | 33 | # errors |
34 | 34 | class Error < StandardError; end |
35 | 35 | class MissingIndexError < Error; end |
36 | - class UnsupportedVersionError < Error; end | |
36 | + class UnsupportedVersionError < Error | |
37 | + def message | |
38 | + "This version of Searchkick requires OpenSearch 1+ or Elasticsearch 7+" | |
39 | + end | |
40 | + end | |
37 | 41 | class InvalidQueryError < Error; end |
38 | 42 | class DangerousOperation < Error; end |
39 | 43 | class ImportError < Error; end | ... | ... |
lib/searchkick/index.rb
... | ... | @@ -359,7 +359,7 @@ module Searchkick |
359 | 359 | end |
360 | 360 | rescue => e |
361 | 361 | if Searchkick.transport_error?(e) && e.message.include?("No handler for type [text]") |
362 | - raise UnsupportedVersionError, "This version of Searchkick requires Elasticsearch 6 or greater" | |
362 | + raise UnsupportedVersionError | |
363 | 363 | end |
364 | 364 | |
365 | 365 | raise e | ... | ... |
lib/searchkick/query.rb
... | ... | @@ -210,14 +210,14 @@ module Searchkick |
210 | 210 | e.message.include?("No query registered for [function_score]") |
211 | 211 | ) |
212 | 212 | |
213 | - raise UnsupportedVersionError, "This version of Searchkick requires Elasticsearch 5 or greater" | |
213 | + raise UnsupportedVersionError | |
214 | 214 | elsif status_code == 400 |
215 | 215 | if ( |
216 | 216 | e.message.include?("bool query does not support [filter]") || |
217 | 217 | e.message.include?("[bool] filter does not support [filter]") |
218 | 218 | ) |
219 | 219 | |
220 | - raise UnsupportedVersionError, "This version of Searchkick requires Elasticsearch 5 or greater" | |
220 | + raise UnsupportedVersionError | |
221 | 221 | elsif e.message =~ /analyzer \[searchkick_.+\] not found/ |
222 | 222 | raise InvalidQueryError, "Bad mapping - run #{reindex_command}" |
223 | 223 | else | ... | ... |