File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 } \n JSON:\n #{ json } "
81- end
8285 end
8386end
You can’t perform that action at this time.
0 commit comments