From dc032b349c1b6f42132cbed446764019e08016c5 Mon Sep 17 00:00:00 2001 From: Noam Meltzer Date: Tue, 19 Jan 2016 21:49:38 +0200 Subject: [PATCH] _try_except_req(): catch httplib.HTTPException fixes #153 --- telegram/utils/request.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/telegram/utils/request.py b/telegram/utils/request.py index 63059a704..e5493f00b 100644 --- a/telegram/utils/request.py +++ b/telegram/utils/request.py @@ -25,6 +25,13 @@ import json import socket from ssl import SSLError +try: + # python2 + from httplib import HTTPException +except ImportError: + # python3 + from http.client import HTTPException + try: from urllib.request import urlopen, urlretrieve, Request from urllib.error import HTTPError @@ -82,6 +89,8 @@ def _try_except_req(func): raise TelegramError("Timed out") raise TelegramError(str(error)) + except HTTPException as error: + raise TelegramError('HTTPException: {0!r}'.format(error)) return decorator