11# frozen_string_literal: true
22
3- module MeiliSearch
3+ module Meilisearch
44 class Error < StandardError
55 end
66
77 class ApiError < Error
88 # :http_code # e.g. 400, 404...
99 # :http_message # e.g. Bad Request, Not Found...
10- # :http_body # The response body received from the MeiliSearch API
11- # :ms_code # The error code given by the MeiliSearch API
12- # :ms_type # The error type given by the MeiliSearch API
13- # :ms_link # The documentation link given by the MeiliSearch API
14- # :ms_message # The error message given by the MeiliSearch API
10+ # :http_body # The response body received from the Meilisearch API
11+ # :ms_code # The error code given by the Meilisearch API
12+ # :ms_type # The error type given by the Meilisearch API
13+ # :ms_link # The documentation link given by the Meilisearch API
14+ # :ms_message # The error message given by the Meilisearch API
1515 # :message # The detailed error message of this error class
1616
1717 attr_reader :http_code , :http_message , :http_body , :ms_code , :ms_type , :ms_link , :ms_message , :message
@@ -26,7 +26,7 @@ def initialize(http_code, http_message, http_body)
2626 @http_body = parse_body ( http_body )
2727 @ms_code = @http_body [ 'code' ]
2828 @ms_type = @http_body [ 'type' ]
29- @ms_message = @http_body . fetch ( 'message' , 'MeiliSearch API has not returned any error message' )
29+ @ms_message = @http_body . fetch ( 'message' , 'Meilisearch API has not returned any error message' )
3030 @ms_link = @http_body . fetch ( 'link' , '<no documentation link found>' )
3131 @message = "#{ http_code } #{ http_message } - #{ @ms_message } . See #{ ms_link } ."
3232 super ( details )
@@ -41,22 +41,22 @@ def parse_body(http_body)
4141 { }
4242 end
4343 rescue JSON ::ParserError
44- # We might receive a JSON::ParserError when, for example, MeiliSearch is running behind
44+ # We might receive a JSON::ParserError when, for example, Meilisearch is running behind
4545 # some proxy (ELB or Nginx, for example), and the request timeouts, returning us
4646 # a raw HTML body instead of a JSON as we were expecting
4747 { 'message' => "The server has not returned a valid JSON HTTP body: #{ http_body } " }
4848 end
4949
5050 def details
51- "MeiliSearch ::ApiError - code: #{ @ms_code } - type: #{ ms_type } - message: #{ @ms_message } - link: #{ ms_link } "
51+ "Meilisearch ::ApiError - code: #{ @ms_code } - type: #{ ms_type } - message: #{ @ms_message } - link: #{ ms_link } "
5252 end
5353 end
5454
5555 class CommunicationError < Error
5656 attr_reader :message
5757
5858 def initialize ( message )
59- @message = "An error occurred while trying to connect to the MeiliSearch instance: #{ message } "
59+ @message = "An error occurred while trying to connect to the Meilisearch instance: #{ message } "
6060 super ( @message )
6161 end
6262 end
@@ -80,8 +80,8 @@ def initialize(message = nil)
8080 end
8181
8282 module TenantToken
83- class ExpireOrInvalidSignature < MeiliSearch ::Error ; end
84- class InvalidApiKey < MeiliSearch ::Error ; end
85- class InvalidSearchRules < MeiliSearch ::Error ; end
83+ class ExpireOrInvalidSignature < Meilisearch ::Error ; end
84+ class InvalidApiKey < Meilisearch ::Error ; end
85+ class InvalidSearchRules < Meilisearch ::Error ; end
8686 end
8787end
0 commit comments