VingtCinq / python-mailchimp

Python client for v3 of MailChimp API
MIT License
463 stars 131 forks source link

Add response object in all MailChimpError exceptions #231

Closed Clepsyd closed 1 year ago

Clepsyd commented 4 years ago

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", '')
shelldandy commented 4 years ago

lol how did that happen

charlesthk commented 1 year ago

Thanks @Clepsyd for your PR, published on pypi in 3.0.20 version