Exception: Camdram::Error::CamdramError
- Inherits:
-
StandardError
- Object
- StandardError
- Camdram::Error::CamdramError
- Defined in:
- lib/camdram/error.rb
Overview
Error class for Camdram API calls
Direct Known Subclasses
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#error_description ⇒ Object
readonly
Returns the value of attribute error_description.
-
#http_headers ⇒ Object
readonly
Returns the value of attribute http_headers.
-
#http_status_code ⇒ Object
readonly
Returns the value of attribute http_status_code.
-
#response_body ⇒ Object
readonly
Returns the value of attribute response_body.
Instance Method Summary collapse
-
#initialize(code, body, headers) ⇒ CamdramError
constructor
A new instance of CamdramError.
Constructor Details
#initialize(code, body, headers) ⇒ CamdramError
Returns a new instance of CamdramError.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/camdram/error.rb', line 14 def initialize(code, body, headers) @http_status_code = code @response_body = body @http_headers = headers # Camdram doesn't always return errors in JSON format # and when it does, the format is sometimes inconsistent begin error_hash = JSON.parse(@response_body) @error = error_hash['error'] @error_description = error_hash['error_description'] rescue JSON::ParserError => e # FIXME come up with a better solution for this @error = http_status_code @error_description = response_body end = "#{error}: #{error_description}" super() raise self end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
12 13 14 |
# File 'lib/camdram/error.rb', line 12 def error @error end |
#error_description ⇒ Object (readonly)
Returns the value of attribute error_description.
12 13 14 |
# File 'lib/camdram/error.rb', line 12 def error_description @error_description end |
#http_headers ⇒ Object (readonly)
Returns the value of attribute http_headers.
11 12 13 |
# File 'lib/camdram/error.rb', line 11 def http_headers @http_headers end |
#http_status_code ⇒ Object (readonly)
Returns the value of attribute http_status_code.
11 12 13 |
# File 'lib/camdram/error.rb', line 11 def http_status_code @http_status_code end |
#response_body ⇒ Object (readonly)
Returns the value of attribute response_body.
11 12 13 |
# File 'lib/camdram/error.rb', line 11 def response_body @response_body end |