File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 66 import urllib .request as urllib_request
77 from urllib .parse import urlencode
88 from urllib .error import HTTPError
9+ from urllib .error import URLError
910except ImportError : # Python 2
1011 import urllib2 as urllib_request
1112 from urllib2 import HTTPError
13+ from urllib2 import URLError
1214 from urllib import urlencode
1315
1416from .exceptions import SendGridClientError , SendGridServerError
@@ -121,6 +123,8 @@ def _legacy_send(self, message):
121123 return self ._make_request (message )
122124 except HTTPError as e :
123125 return e .code , e .read ()
126+ except URLError as e :
127+ return 408 , e .reason
124128 except timeout as e :
125129 return 408 , e
126130
@@ -134,5 +138,7 @@ def _raising_send(self, message):
134138 raise SendGridServerError (e .code , e .read ())
135139 else :
136140 assert False
141+ except URLError as e :
142+ raise SendGridClientError (408 , 'Request timeout' )
137143 except timeout as e :
138144 raise SendGridClientError (408 , 'Request timeout' )
You can’t perform that action at this time.
0 commit comments