diff --git a/lib/active_campaign/errors.rb b/lib/active_campaign/errors.rb index 6132438..bf79ac6 100644 --- a/lib/active_campaign/errors.rb +++ b/lib/active_campaign/errors.rb @@ -28,14 +28,18 @@ 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 + begin + <<~MESSAGE + STATUS: #{response.try(: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 + rescue StandardError => e + super + end end end diff --git a/lib/active_campaign/faraday/middleware/request.rb b/lib/active_campaign/faraday/middleware/request.rb index 997b7a4..5bcdace 100644 --- a/lib/active_campaign/faraday/middleware/request.rb +++ b/lib/active_campaign/faraday/middleware/request.rb @@ -35,6 +35,8 @@ def normalize_body(env) logger.debug("Using body as is because group #{body}") elsif body.key?(:list) logger.debug("Using body as is because list #{body}") + elsif body.key?(:contacts) && body.key?(:callback) + logger.debug("Using body as is because contacts+callback #{body}") else body = transform_keys(body, :camelcase, :lower) end