Exception: EasyPing::APIError
- Defined in:
- lib/easy_ping/error.rb
Overview
Wrap error responded from server side
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#param ⇒ Object
readonly
Returns the value of attribute param.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(response) ⇒ APIError
constructor
A new instance of APIError.
Methods inherited from Error
Constructor Details
#initialize(response) ⇒ APIError
Returns a new instance of APIError.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/easy_ping/error.rb', line 27 def initialize(response) @status = response.status @error = JSON.parse(response.body)['error'] rescue {} @type = @error['type'] @code = @error['code'] @param = @error['param'] = @error['message'] = "Server responded with status #{@status}." += " Full Message: #{@message}." if super() end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
26 27 28 |
# File 'lib/easy_ping/error.rb', line 26 def code @code end |
#param ⇒ Object (readonly)
Returns the value of attribute param.
26 27 28 |
# File 'lib/easy_ping/error.rb', line 26 def param @param end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
26 27 28 |
# File 'lib/easy_ping/error.rb', line 26 def status @status end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
26 27 28 |
# File 'lib/easy_ping/error.rb', line 26 def type @type end |