Exception: Workarea::Listrak::HttpError
- Inherits:
-
StandardError
- Object
- StandardError
- Workarea::Listrak::HttpError
- Defined in:
- lib/workarea/listrak/error.rb
Instance Attribute Summary collapse
-
#http_response ⇒ Object
readonly
Returns the value of attribute http_response.
Instance Method Summary collapse
- #api_message ⇒ Object
- #body ⇒ Object
- #error_code ⇒ Object
-
#initialize(http_response) ⇒ HttpError
constructor
A new instance of HttpError.
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_response ⇒ Object (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_message ⇒ Object
34 35 36 |
# File 'lib/workarea/listrak/error.rb', line 34 def body["message"] rescue nil end |
#body ⇒ Object
26 27 28 |
# File 'lib/workarea/listrak/error.rb', line 26 def body @body ||= JSON.parse(http_response.body) rescue nil end |
#error_code ⇒ Object
30 31 32 |
# File 'lib/workarea/listrak/error.rb', line 30 def error_code body["error"] rescue nil end |