Skip to content

Commit aab5578

Browse files
committed
fix(cli+sdk): minor fixes
1 parent ec2e155 commit aab5578

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

cli/kleinkram/cli/_executions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ def launch(
7777
mission_query=mission_query,
7878
template=template_name,
7979
)
80-
except kleinkram.errors.InvalidMissionQuery:
81-
raise kleinkram.errors.InvalidMissionQuery("Mission query is ambiguous. Try specifying a project with -p.")
80+
except kleinkram.errors.InvalidMissionQuery as e:
81+
raise kleinkram.errors.InvalidMissionQuery("Mission query is ambiguous. Try specifying a project with -p.") from e
8282
typer.secho(f"Action submitted. Execution ID: {execution_uuid}", fg=typer.colors.GREEN)
8383

8484
if follow:

cli/kleinkram/cli/error_handling.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def display_error(
7575
)
7676
Console(file=sys.stderr).print(panel)
7777
else:
78-
if title and message:
78+
if title is not None or message is not None:
7979
print(body, file=sys.stderr)
8080
else:
8181
text = f"{type(exc).__name__}"
@@ -91,8 +91,7 @@ def handle_request_error(exc: httpx.RequestError) -> int:
9191
selected_endpoint = config.selected_endpoint
9292
endpoint_url = config.endpoint.api
9393

94-
# Categorize the request error
95-
if isinstance(exc, (httpx.ConnectError, httpx.ConnectTimeout, httpx.NetworkError)):
94+
if isinstance(exc, (httpx.ConnectError, httpx.ConnectTimeout)):
9695
title = "Connection Failed"
9796
msg = (
9897
f"Unable to connect to the Kleinkram backend server at:\n"

cli/tests/test_error_handling.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@ def test_handle_generic_exception_debug():
140140
"Error: Network error on http://my-api-url.com (Invalid)",
141141
False,
142142
),
143+
(
144+
httpx.ReadError("connection reset", request=MagicMock()),
145+
True,
146+
False,
147+
"Network Error",
148+
["Details: connection reset", "http://my-api-url.com"],
149+
False,
150+
),
151+
(
152+
httpx.WriteError("write failed", request=MagicMock()),
153+
True,
154+
False,
155+
"Network Error",
156+
["Details: write failed", "http://my-api-url.com"],
157+
False,
158+
),
143159
],
144160
)
145161
def test_handle_request_error_parameterized(capsys, exc, verbose, debug, expected_title, expected_texts, should_raise):

0 commit comments

Comments
 (0)