Exception: MailChimp3::Errors::BaseError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/mailchimp3/errors.rb

Direct Known Subclasses

ClientError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#detailsObject (readonly)

Returns the value of attribute details.



7
8
9
# File 'lib/mailchimp3/errors.rb', line 7

def details
  @details
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/mailchimp3/errors.rb', line 7

def status
  @status
end

Instance Method Details

#inspectObject



25
26
27
# File 'lib/mailchimp3/errors.rb', line 25

def inspect
  "<#{self.class.name} status=#{@status} message=#{@message}>"
end

#to_sObject



21
22
23
# File 'lib/mailchimp3/errors.rb', line 21

def to_s
  @message
end