Exception: Algolia::AlgoliaHttpError

Inherits:
AlgoliaError
  • Object
show all
Defined in:
lib/algolia/error.rb

Overview

An exception class raised when the REST API returns an error. The error code and message will be parsed out of the HTTP response, which is also included in the response attribute.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, message, correlation_id = nil) ⇒ AlgoliaHttpError

Returns a new instance of AlgoliaHttpError.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/algolia/error.rb', line 43

def initialize(code, message, correlation_id = nil)
  self.code = code
  self.http_message = message
  @correlation_id = correlation_id

  if correlation_id.nil? || correlation_id.empty?
    super("#{code}: #{message}")
  else
    super("#{code}: #{message} (Correlation-ID: #{correlation_id})")
  end
end

Instance Attribute Details

#code ⇒ Object

Returns the value of attribute code.



37
38
39
# File 'lib/algolia/error.rb', line 37

def code
  @code
end

#correlation_id ⇒ Object (readonly)

The Correlation-ID header of the failed response (possibly ""), or nil. Quote it when contacting Algolia support.



41
42
43
# File 'lib/algolia/error.rb', line 41

def correlation_id
  @correlation_id
end

#http_message ⇒ Object

Returns the value of attribute http_message.



37
38
39
# File 'lib/algolia/error.rb', line 37

def http_message
  @http_message
end