Skip to content

Commit f90c2ff

Browse files
committed
Add exception handler to delete_documents method
This will increase the DX when the user tries to use a route method that are not defined in the current Meilisearch instance they are using.
1 parent cac0f17 commit f90c2ff

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/meilisearch/index.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,14 @@ def update_documents_in_batches!(documents, batch_size = 1000, primary_key = nil
161161
#
162162
# Returns a Task object.
163163
def delete_documents(documents_ids = nil, filter: nil)
164-
if documents_ids.nil?
165-
http_post "/indexes/#{@uid}/documents/delete", { filter: filter }
166-
else
167-
documents_ids = [documents_ids] unless documents_ids.is_a?(Array)
168-
169-
http_post "/indexes/#{@uid}/documents/delete-batch", documents_ids
164+
MeiliSearch::Utils.version_error_handler(__method__) do
165+
if documents_ids.nil?
166+
http_post "/indexes/#{@uid}/documents/delete", { filter: filter }
167+
else
168+
documents_ids = [documents_ids] unless documents_ids.is_a?(Array)
169+
170+
http_post "/indexes/#{@uid}/documents/delete-batch", documents_ids
171+
end
170172
end
171173
end
172174
alias delete_multiple_documents delete_documents

0 commit comments

Comments
 (0)