-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better error handling #165
Comments
Hi We would be happy to see a PR for what you describe. The current wrapper leaves all error checking in the hands of the users, but if there are any standard errors that you want to provide specific notifications and messages for, we will be glad to take a look at the PR. If you are processing a specific error, please make sure you process that error on every endpoint that raises it. |
The three classes of errors I've encountered so far is:
|
Hello everyone! Is there a way I can convert "Mailchimperror" to json format? so I can use it on my web microservice. |
MailChimpError is a custom python exception that we pass json data into, if you wrap your code in a try/except block catching the MailChimpError, you can pull that data out depending on your python version and serve the message information directly. |
Is this the correct way to access the exception data? try:
response = client.lists.webhooks.create(...)
except MailChimpError as ex:
if 'errors' in ex.args[0]:
raise UserError(ex.args[0]['errors'][0]['message']) #
else:
raise ex |
Hey there,
first of all thanks for the library!
I would welcome to have better error handling as currently the Error reply is put as JSON into the Exception and not really parsed in anyway.
This makes hard to handle errors which might not really be errors in the application contexts (for example duplicated emails in a list).
I would suggest to extend the current
MailChimpError
class with status, title and details attribute. Maybe even subclass this class with frequently handled errors, for example like the duplicated emails usecase. Do you know about any other error which would be good to create a subclass for?I could make PR for this if you would like me to. Please let me know if you would except it.
The text was updated successfully, but these errors were encountered: