Exception: Flex::HttpError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/flex/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#responseObject (readonly)

Returns the value of attribute response.



15
16
17
# File 'lib/flex/errors.rb', line 15

def response
  @response
end

Instance Method Details

#bodyObject



26
27
28
# File 'lib/flex/errors.rb', line 26

def body
  response.body
end

#statusObject



22
23
24
# File 'lib/flex/errors.rb', line 22

def status
  response.status
end

#to_hashObject



35
36
37
38
39
# File 'lib/flex/errors.rb', line 35

def to_hash
  MultiJson.decode response.body
rescue MultiJson::DecodeError
  {}
end

#to_sObject



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