Personal AI, On Personal Devices
Python
fix(tools): report FXMacroData timeouts as timeouts
Robert Tidball8791939c17ae
diff --git a/src/openjarvis/tools/fx_macro.py b/src/openjarvis/tools/fx_macro.pyindex d896e6ae..3ae2423d 100644--- a/src/openjarvis/tools/fx_macro.py+++ b/src/openjarvis/tools/fx_macro.py@@ -57,6 +57,8 @@ def _api_get(path: str, params: dict[str, str], api_key: str | None) -> Any:timeout=30.0,follow_redirects=False,)+ except httpx.TimeoutException:+ raise FXMacroDataError("FXMacroData did not answer in time") from Noneexcept httpx.HTTPError:# Transport errors can format the request; never interpolate them.raise FXMacroDataError("FXMacroData could not be reached") from Nonediff --git a/tests/tools/test_fx_macro.py b/tests/tools/test_fx_macro.pyindex c6764ee3..6039d6ba 100644--- a/tests/tools/test_fx_macro.py+++ b/tests/tools/test_fx_macro.py@@ -160,6 +160,14 @@ def test_transport_error_text_is_never_interpolated():)+def test_timeout_is_reported_as_such():+ with patch(_GET, side_effect=httpx.ReadTimeout(f"slow {_KEY}")):+ result = _run(action="indicator_catalogue", currency="USD")+ assert result.content == (+ "FXMacroData lookup failed: FXMacroData did not answer in time"+ )++def test_unexpected_exception_is_generic():with patch(_GET, side_effect=RuntimeError(_KEY)):result = _run(action="indicator_catalogue", currency="USD")