Exception: Workarea::Listrak::HttpError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/workarea/listrak/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ HttpError

Returns a new instance of HttpError.



21
22
23
24
# File 'lib/workarea/listrak/error.rb', line 21

def initialize(http_response)
  @http_response = http_response
  super(http_response.body)
end

Instance Attribute Details

#http_responseObject (readonly)

Returns the value of attribute http_response.



19
20
21
# File 'lib/workarea/listrak/error.rb', line 19

def http_response
  @http_response
end

Instance Method Details

#api_messageObject



34
35
36
# File 'lib/workarea/listrak/error.rb', line 34

def api_message
  body["message"] rescue nil
end

#bodyObject



26
27
28
# File 'lib/workarea/listrak/error.rb', line 26

def body
  @body ||= JSON.parse(http_response.body) rescue nil
end

#error_codeObject



30
31
32
# File 'lib/workarea/listrak/error.rb', line 30

def error_code
  body["error"] rescue nil
end