From 576594ec99e99f16f49f84114e36ded82e89885f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dannie=20Ha=CC=8Akansson?= Date: Fri, 27 Oct 2017 14:19:33 +0200 Subject: [PATCH] Fixed: Issue where HTTPError would not be caught correctly --- sgbackend/mail.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sgbackend/mail.py b/sgbackend/mail.py index 5f83b40..a1ce668 100644 --- a/sgbackend/mail.py +++ b/sgbackend/mail.py @@ -4,11 +4,6 @@ import sys from email.mime.base import MIMEBase -try: - from urllib.error import HTTPError # pragma: no cover -except ImportError: # pragma: no cover - from urllib2 import HTTPError # pragma: no cover - try: import rfc822 except ImportError: @@ -18,6 +13,7 @@ from django.core.exceptions import ImproperlyConfigured from django.core.mail import EmailMultiAlternatives from django.core.mail.backends.base import BaseEmailBackend +from python_http_client import exceptions import sendgrid from sendgrid.helpers.mail import ( @@ -63,7 +59,7 @@ def send_messages(self, emails): try: self.sg.client.mail.send.post(request_body=mail) count += 1 - except HTTPError as e: + except exceptions.HTTPError as e: if not self.fail_silently: raise return count