This allows any exception to be examined with more detail, even when the response contains JSON data, by consistently including the response object.
e.g a 404 response might not have JSON data, and we still might want to know which requests lead to this:
try:
# any client method call
except MailChimpError as e:
# We can reliably get the ;response from the exception, and any of its attached data
request = e.args["response"].request
# And still use the JSON data
detail = e.args.get("detail", '')
This allows any exception to be examined with more detail, even when the response contains JSON data, by consistently including the response object.
e.g a 404 response might not have JSON data, and we still might want to know which requests lead to this: