Skip to content

Commit fe26c94

Browse files
committed
Merge pull request python-telegram-bot#155 from tsnoam/master
_try_except_req(): catch httplib.HTTPException
2 parents 6166e7f + dc032b3 commit fe26c94

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

telegram/utils/request.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
import socket
2626
from ssl import SSLError
2727

28+
try:
29+
# python2
30+
from httplib import HTTPException
31+
except ImportError:
32+
# python3
33+
from http.client import HTTPException
34+
2835
try:
2936
from urllib.request import urlopen, urlretrieve, Request
3037
from urllib.error import HTTPError
@@ -82,6 +89,8 @@ def decorator(*args, **kwargs):
8289
raise TelegramError("Timed out")
8390

8491
raise TelegramError(str(error))
92+
except HTTPException as error:
93+
raise TelegramError('HTTPException: {0!r}'.format(error))
8594

8695
return decorator
8796

0 commit comments

Comments
 (0)