Skip to content

Commit b33dc65

Browse files
committed
Handle request connection timeouts
1 parent 806196d commit b33dc65

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

okdata/cli/__main__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from keycloak.exceptions import KeycloakGetError, KeycloakPostError
66
from okdata.sdk.exceptions import ApiAuthenticateError
7-
from requests.exceptions import RequestException
7+
from requests.exceptions import ConnectTimeout, RequestException
88

99
from okdata.cli import MAINTAINER
1010
from okdata.cli.command import BaseCommand
@@ -37,6 +37,11 @@ def main():
3737
# Flush output here to force SIGPIPE to be triggered while inside
3838
# this try block.
3939
sys.stdout.flush()
40+
except ConnectTimeout as e:
41+
instance.print(
42+
f"Connection to '{e.request.url}' timed out. Please try again, "
43+
f"or contact {MAINTAINER} if the problem persists.",
44+
)
4045
except RequestException as e:
4146
if hasattr(e.response, "json"):
4247
instance.print_error_response(e.response.json())

0 commit comments

Comments
 (0)