Skip to content

Commit

Permalink
Merge pull request #328 from alphagov/ris-mc-subscribe-robust
Browse files Browse the repository at this point in the history
DMMailChimpClient: make subscribe_new_email_to_list more robust to exceptions
  • Loading branch information
risicle committed Sep 11, 2017
2 parents 4a6682b + 4ae2af6 commit 2ec055c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dmutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
import flask_featureflags # noqa


__version__ = '28.0.2'
__version__ = '28.0.3'
4 changes: 3 additions & 1 deletion dmutils/email/dm_mailchimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def subscribe_new_email_to_list(self, list_id, email_address):
# mailchimp to never add them to mailchimp lists. In this case, we resort to allowing a failed API call (but
# log) as a user of this method would unlikely be able to do anything as we have no control over this
# behaviour.
if "looks fake or invalid, please enter a real email address." in e.response.json()["detail"]:
if getattr(e, "response", None) and (
"looks fake or invalid, please enter a real email address." in e.response.json()["detail"]
):
self.logger.error(
"Expected error: Mailchimp failed to add user ({}) to list ({}). API error: The email address looks fake or invalid, please enter a real email address.".format( # noqa
hashed_email,
Expand Down

0 comments on commit 2ec055c

Please sign in to comment.