Skip to content

Commit c890aa7

Browse files
fix: Handle case when client returns a 500 error without a JSON response
1 parent e5a7c96 commit c890aa7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/meilisearch/error.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ def get_meilisearch_error_info(http_body)
3333
@ms_message = @http_body['message']
3434
@ms_type = @http_body['errorType']
3535
@ms_link = @http_body['errorLink']
36+
rescue JSON::ParserError
37+
# We might receive a JSON::ParserError when, for example, MeiliSearch is running behind
38+
# some proxy (ELB or Nginx, for example), and the request timeouts, returning us
39+
# a raw HTML body instead of a JSON as we were expecting
40+
@ms_message = "MeiliSearch API has not returned a valid JSON HTTP body: #{http_body}"
3641
end
3742

3843
def details

0 commit comments

Comments
 (0)