Exception: ActiveCampaignRb::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/active_campaign_rb/errors.rb

Overview

Base class error for almost all exceptions

Author:

Direct Known Subclasses

ClientError, ConnectionFailed, SSLError, ServerError

Instance Method Summary collapse

Constructor Details

#initialize(response = nil, exception = nil) ⇒ Error

Returns a new instance of Error.



10
11
12
13
14
# File 'lib/active_campaign_rb/errors.rb', line 10

def initialize(response = nil, exception = nil)
  self.response = response
  @exception    = exception
  super
end

Instance Method Details

#messageObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/active_campaign_rb/errors.rb', line 16

def message
  if response.nil?
    super
  else
    <<~MESSAGE
      STATUS: #{response.status}
      URL: #{env.url}
      REQUEST HEADERS: #{env.request_headers}
      RESPONSE_HEADERS: #{env.response_headers}
      REQUEST_BODY: #{env.request_body}\n\n"
      RESPONSE_BODY: #{response.body}\n\n"
    MESSAGE
  end
end