Exception: MailChimp3::Errors::BaseError
- Inherits:
-
StandardError
- Object
- StandardError
- MailChimp3::Errors::BaseError
- Defined in:
- lib/mailchimp3/errors.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(body:, status:) ⇒ BaseError
constructor
A new instance of BaseError.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(body:, status:) ⇒ BaseError
Returns a new instance of BaseError.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mailchimp3/errors.rb', line 9 def initialize(body:, status:) @status = status @message = if body.is_a?(Hash) && body['error'] "#{body['name']}: #{body['error']}" elsif body.is_a?(Hash) "#{body['title']}: #{body['detail']}" else body.to_s end @details = body if body.is_a?(Hash) end |
Instance Attribute Details
#details ⇒ Object (readonly)
Returns the value of attribute details.
7 8 9 |
# File 'lib/mailchimp3/errors.rb', line 7 def details @details end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/mailchimp3/errors.rb', line 7 def status @status end |
Instance Method Details
#inspect ⇒ Object
25 26 27 |
# File 'lib/mailchimp3/errors.rb', line 25 def inspect "<#{self.class.name} status=#{@status} message=#{@message}>" end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/mailchimp3/errors.rb', line 21 def to_s @message end |