diff options
author | Stephen Finucane <stephenfinucane@hotmail.com> | 2016-09-08 17:43:10 +0100 |
---|---|---|
committer | Stephen Finucane <stephenfinucane@hotmail.com> | 2016-09-25 00:00:18 +0100 |
commit | 02cf4f511c1d0e45eca59263cf49838592f9e3bd (patch) | |
tree | 652cc6e87e022ac79506b83b6a6738b58fef7dc4 /patchwork/notifications.py | |
parent | d848f046503dacc5423a840d483fe7e5edc07ca3 (diff) | |
download | patchwork-02cf4f511c1d0e45eca59263cf49838592f9e3bd.tar patchwork-02cf4f511c1d0e45eca59263cf49838592f9e3bd.tar.gz |
trivial: Remove broad exceptions where possible
The are two somewhat significant changes:
* The behavior of 'Bundle.add_patch' is changed. Previously this would
raise an exception if the provided patch already existed in the
bundle. Since this code was only used in one location, change this to
return the BundlePatch if valid else None and change the calling code
to check return value instead of catching the exception.
* Use a context manager to open the config file in pwclient. This loses
a little granularity in error messaging, but this is a worthy
compromise.
Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Diffstat (limited to 'patchwork/notifications.py')
-rw-r--r-- | patchwork/notifications.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/patchwork/notifications.py b/patchwork/notifications.py index 5420401..16152ef 100644 --- a/patchwork/notifications.py +++ b/patchwork/notifications.py @@ -19,6 +19,7 @@ import datetime import itertools +import smtplib from django.conf import settings from django.contrib.auth.models import User @@ -87,7 +88,7 @@ def send_notifications(): try: message.send() - except Exception as ex: + except smtplib.SMTPException as ex: errors.append((recipient, ex)) continue |