Exception: KahunaClient::Error
- Inherits:
-
StandardError
- Object
- StandardError
- KahunaClient::Error
- Defined in:
- lib/kahuna_client/error.rb
Overview
Custom error class for rescuing from all KahunaClient errors
Instance Attribute Summary collapse
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(message, status = nil, data = nil) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message, status = nil, data = nil) ⇒ Error
Returns a new instance of Error.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kahuna_client/error.rb', line 8 def initialize(, status=nil, data=nil) super() @status = status if data begin json_hash = MultiJson.load(data, symbolize_keys: true) @error_code = json_hash[:error_code] # should be the same as the HTTP status @error_message = json_hash[:error] rescue MultiJson::ParseError => exception # nothing to do end end end |
Instance Attribute Details
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
6 7 8 |
# File 'lib/kahuna_client/error.rb', line 6 def error_code @error_code end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
6 7 8 |
# File 'lib/kahuna_client/error.rb', line 6 def @error_message end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/kahuna_client/error.rb', line 6 def status @status end |