Exception: Mautic::RequestError
- Inherits:
-
StandardError
- Object
- StandardError
- Mautic::RequestError
- Defined in:
- lib/mautic.rb
Direct Known Subclasses
AuthorizeError, RecordNotFound, TokenExpiredError, ValidationError
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response, message = nil) ⇒ RequestError
constructor
A new instance of RequestError.
Constructor Details
#initialize(response, message = nil) ⇒ RequestError
Returns a new instance of RequestError.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mautic.rb', line 15 def initialize(response, = nil) @errors ||= [] @response = response json_body = JSON.parse(response.body) rescue {} ||= Array(json_body['errors']).collect do |error| msg = error['code'].to_s msg << " (#{error['type']}):" if error['type'] msg << " #{error['message']}" @errors << error['message'] msg end.join(', ') super() end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
13 14 15 |
# File 'lib/mautic.rb', line 13 def errors @errors end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
13 14 15 |
# File 'lib/mautic.rb', line 13 def response @response end |