mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 23:27:49 +01:00
improve error handling on timeouts
This commit is contained in:
parent
206802cf4d
commit
0b4c23f50e
1 changed files with 4 additions and 3 deletions
|
@ -20,6 +20,7 @@
|
||||||
"""This module contains methods to make POST and GET requests"""
|
"""This module contains methods to make POST and GET requests"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import socket
|
||||||
from ssl import SSLError
|
from ssl import SSLError
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -111,11 +112,11 @@ def post(url,
|
||||||
|
|
||||||
message = _parse(error.read())
|
message = _parse(error.read())
|
||||||
raise TelegramError(message)
|
raise TelegramError(message)
|
||||||
except SSLError as error:
|
except (SSLError, socket.timeout) as error:
|
||||||
if "operation timed out" in error.message:
|
if "operation timed out" in str(error):
|
||||||
raise TelegramError("Timed out")
|
raise TelegramError("Timed out")
|
||||||
|
|
||||||
raise TelegramError(error.message)
|
raise TelegramError(str(error))
|
||||||
return _parse(result)
|
return _parse(result)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue