Exception: Algolia::AlgoliaHttpError
- Inherits:
-
AlgoliaError
- Object
- StandardError
- AlgoliaError
- Algolia::AlgoliaHttpError
- 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
-
#code ⇒ Object
Returns the value of attribute code.
-
#correlation_id ⇒ Object
readonly
The Correlation-ID header of the failed response (possibly ""), or nil.
-
#http_message ⇒ Object
Returns the value of attribute http_message.
Instance Method Summary collapse
-
#initialize(code, message, correlation_id = nil) ⇒ AlgoliaHttpError
constructor
A new instance of AlgoliaHttpError.
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, , correlation_id = nil) self.code = code self. = @correlation_id = correlation_id if correlation_id.nil? || correlation_id.empty? super("#{code}: #{}") else super("#{code}: #{} (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 end |