From 773d0874d5a25a3c0670eb12a36119587b4f6701 Mon Sep 17 00:00:00 2001 From: Jacob Nelson Date: Sun, 23 Aug 2026 17:04:54 -0500 Subject: [PATCH] fix(agent): wrap transport errors in FireflyError --- agent/src/agent/firefly.py | 7 ++++++- agent/tests/test_firefly.py | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/agent/src/agent/firefly.py b/agent/src/agent/firefly.py index b588b22..2624b5a 100644 --- a/agent/src/agent/firefly.py +++ b/agent/src/agent/firefly.py @@ -27,7 +27,12 @@ class FireflyClient: ) def _get(self, path: str, params: dict | None = None) -> dict: - response = self._http.get(path, params=params) + try: + response = self._http.get(path, params=params) + except httpx.HTTPError as exc: + raise FireflyError( + f"GET {path} failed: {type(exc).__name__}: {exc}" + ) from exc if response.status_code != 200: raise FireflyError( f"GET {path} -> {response.status_code}: {response.text[:200]}" diff --git a/agent/tests/test_firefly.py b/agent/tests/test_firefly.py index efc64d5..5d54dc7 100644 --- a/agent/tests/test_firefly.py +++ b/agent/tests/test_firefly.py @@ -47,3 +47,11 @@ def test_accounts_walks_all_pages(): accounts = make_client(handler).accounts() assert [a["attributes"]["name"] for a in accounts] == ["NFCU Checking", "Venmo"] + + +def test_transport_errors_wrapped_in_firefly_error(): + def handler(request: httpx.Request) -> httpx.Response: + raise httpx.ConnectError("connection refused") + + with pytest.raises(FireflyError, match="ConnectError"): + make_client(handler).about()