Skip to content

Commit 0b4c23f

Browse files
committed
improve error handling on timeouts
1 parent 206802c commit 0b4c23f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

telegram/utils/request.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"""This module contains methods to make POST and GET requests"""
2121

2222
import json
23+
import socket
2324
from ssl import SSLError
2425

2526
try:
@@ -111,11 +112,11 @@ def post(url,
111112

112113
message = _parse(error.read())
113114
raise TelegramError(message)
114-
except SSLError as error:
115-
if "operation timed out" in error.message:
115+
except (SSLError, socket.timeout) as error:
116+
if "operation timed out" in str(error):
116117
raise TelegramError("Timed out")
117118

118-
raise TelegramError(error.message)
119+
raise TelegramError(str(error))
119120
return _parse(result)
120121

121122

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy