Exception: Elastics::HttpError
- Inherits:
-
StandardError
- Object
- StandardError
- Elastics::HttpError
- Defined in:
- lib/elastics/errors.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(response, caller_line = nil) ⇒ HttpError
constructor
A new instance of HttpError.
- #status ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(response, caller_line = nil) ⇒ HttpError
Returns a new instance of HttpError.
18 19 20 21 |
# File 'lib/elastics/errors.rb', line 18 def initialize(response, caller_line=nil) @response = response @caller_line = caller_line end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
16 17 18 |
# File 'lib/elastics/errors.rb', line 16 def response @response end |
Instance Method Details
#body ⇒ Object
27 28 29 |
# File 'lib/elastics/errors.rb', line 27 def body response.body end |
#status ⇒ Object
23 24 25 |
# File 'lib/elastics/errors.rb', line 23 def status response.status end |
#to_hash ⇒ Object
36 37 38 39 40 |
# File 'lib/elastics/errors.rb', line 36 def to_hash MultiJson.decode response.body rescue MultiJson::DecodeError {} end |
#to_s ⇒ Object
31 32 33 34 |
# File 'lib/elastics/errors.rb', line 31 def to_s log = "#@caller_line\n" if @caller_line "#{log}#{status}: #{body}" end |