From ccbefe41c069aed8f4b8f81755a4314b0f3f3d95 Mon Sep 17 00:00:00 2001 From: Romain Demeure Date: Thu, 21 Aug 2025 11:22:18 +0200 Subject: [PATCH] :sparkles: feat/catch error when endpoint is not working --- oks_cli/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/oks_cli/utils.py b/oks_cli/utils.py index 1b13087..80da3a3 100644 --- a/oks_cli/utils.py +++ b/oks_cli/utils.py @@ -119,6 +119,10 @@ def do_request(method, path, *args, **kwargs): logging.debug(traceback.format_stack(limit = 4)) raise JSONClickException(err.response.text) + except (requests.exceptions.ConnectionError, requests.exceptions.Timeout) as err: + errors = {"Error": f"Failed to reach the endpoint {url} ({err.__class__.__name__})"} + raise JSONClickException(json.dumps(errors)) + def build_headers(): """Build HTTP headers for API requests based on environment authentication settings.""" headers = {