From 0b4c23f50e86734c98b8ceb5b9cc9a284761060c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Wed, 11 Nov 2015 14:05:57 +0100 Subject: [PATCH] improve error handling on timeouts --- telegram/utils/request.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/telegram/utils/request.py b/telegram/utils/request.py index 29cdcc454..87ccccc4c 100644 --- a/telegram/utils/request.py +++ b/telegram/utils/request.py @@ -20,6 +20,7 @@ """This module contains methods to make POST and GET requests""" import json +import socket from ssl import SSLError try: @@ -111,11 +112,11 @@ def post(url, message = _parse(error.read()) raise TelegramError(message) - except SSLError as error: - if "operation timed out" in error.message: + except (SSLError, socket.timeout) as error: + if "operation timed out" in str(error): raise TelegramError("Timed out") - raise TelegramError(error.message) + raise TelegramError(str(error)) return _parse(result)