Exception: Notifications::Client::RequestError
- Inherits:
-
StandardError
- Object
- StandardError
- Notifications::Client::RequestError
- Defined in:
- lib/notifications/client/request_error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(response) ⇒ RequestError
constructor
A new instance of RequestError.
- #message_from(body) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(response) ⇒ RequestError
6 7 8 9 |
# File 'lib/notifications/client/request_error.rb', line 6 def initialize(response) @code = response.code @message = (response.body) end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/notifications/client/request_error.rb', line 4 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
4 5 6 |
# File 'lib/notifications/client/request_error.rb', line 4 def @message end |
Instance Method Details
#message_from(body) ⇒ Object
15 16 17 18 19 |
# File 'lib/notifications/client/request_error.rb', line 15 def (body) JSON.parse(body).fetch('errors') rescue JSON::ParserError body end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/notifications/client/request_error.rb', line 11 def to_s "#{code} #{}" end |