Exception: IdentityMind::ResponseError
- Inherits:
-
StandardError
- Object
- StandardError
- IdentityMind::ResponseError
- Defined in:
- lib/identity_mind/response_error.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
Instance Method Summary collapse
- #extract_error_message(body) ⇒ Object
-
#initialize(body, code) ⇒ ResponseError
constructor
A new instance of ResponseError.
Constructor Details
#initialize(body, code) ⇒ ResponseError
Returns a new instance of ResponseError.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/identity_mind/response_error.rb', line 5 def initialize(body, code) @code = code @body = body @error_message = (body) super( ["IdentityMind responded with status #{code}", @error_message] .compact.join(' => ') ) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/identity_mind/response_error.rb', line 3 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
3 4 5 |
# File 'lib/identity_mind/response_error.rb', line 3 def code @code end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
3 4 5 |
# File 'lib/identity_mind/response_error.rb', line 3 def @error_message end |
Instance Method Details
#extract_error_message(body) ⇒ Object
16 17 18 19 20 |
# File 'lib/identity_mind/response_error.rb', line 16 def (body) JSON.parse(body)['error_message'] rescue JSON::ParserError nil end |