Skip to content

Commit

Permalink
Fixed: Issue where HTTPError would not be caught correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
dhakan committed Oct 27, 2017
1 parent dc1e512 commit 576594e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions sgbackend/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 (
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 576594e

Please sign in to comment.