Skip to content

Commit f4ecacd

Browse files
committed
Full JSON response
1 parent f6d02d8 commit f4ecacd

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

lib/typesense/documents.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,16 @@ def import(documents, options = {})
4646
)
4747

4848
if documents.is_a?(Array)
49-
results_in_jsonl_format.split("\n").map { |r| json_load(r) }
49+
results_in_jsonl_format.split("\n").map do |r|
50+
begin
51+
Oj.load(r)
52+
rescue Oj::ParseError => e
53+
raise Typesense::Error::ResponseMalformed,
54+
"#{e.message}\n\n" \
55+
"JSON:\n#{r}\n\n" \
56+
"Full JSON:\n#{results_in_jsonl_format}"
57+
end
58+
end
5059
else
5160
results_in_jsonl_format
5261
end
@@ -73,11 +82,5 @@ def delete(query_parameters = {})
7382
def endpoint_path(operation = nil)
7483
"#{Collections::RESOURCE_PATH}/#{@collection_name}#{Documents::RESOURCE_PATH}#{operation.nil? ? '' : "/#{operation}"}"
7584
end
76-
77-
def json_load(json)
78-
Oj.load(json)
79-
rescue Oj::ParseError => e
80-
raise Typesense::Error::ResponseMalformed, "#{e.message}\nJSON:\n#{json}"
81-
end
8285
end
8386
end

0 commit comments

Comments
 (0)