Skip to content

Commit 5b05bcc

Browse files
committed
add http error exception handling
1 parent adb446a commit 5b05bcc

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

telegram/utils/botan.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
try:
66
from urllib.request import urlopen, Request
77
from urllib.parse import quote
8-
from urllib.error import URLError
8+
from urllib.error import URLError, HTTPError
99
except ImportError:
1010
from urllib2 import urlopen, Request
1111
from urllib import quote
12-
from urllib2 import URLError
12+
from urllib2 import URLError, HTTPError
1313

1414

1515
class Botan(object):
@@ -38,7 +38,9 @@ def track(self, message, event_name='event'):
3838
if response.getcode() != 200:
3939
return False
4040
return True
41-
except URLError as error:
41+
except HTTPError as error:
4242
print('botan track error ' + str(error.code) + ':' + error.reason)
43-
print(url)
43+
return False
44+
except URLError as error:
45+
print('botan track error ' + error.reason)
4446
return False

0 commit comments

Comments
 (0)