Exception: Flex::HttpError
- Inherits:
-
StandardError
- Object
- StandardError
- Flex::HttpError
- Defined in:
- lib/flex/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.
17 18 19 20 |
# File 'lib/flex/errors.rb', line 17 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.
15 16 17 |
# File 'lib/flex/errors.rb', line 15 def response @response end |
Instance Method Details
#body ⇒ Object
26 27 28 |
# File 'lib/flex/errors.rb', line 26 def body response.body end |
#status ⇒ Object
22 23 24 |
# File 'lib/flex/errors.rb', line 22 def status response.status end |
#to_hash ⇒ Object
35 36 37 38 39 |
# File 'lib/flex/errors.rb', line 35 def to_hash MultiJson.decode response.body rescue MultiJson::DecodeError {} end |
#to_s ⇒ Object
30 31 32 33 |
# File 'lib/flex/errors.rb', line 30 def to_s log = "#@caller_line\n" if @caller_line "#{log}#{status}: #{body}" end |