Wrap les erreurs httpx du client Frisbii en FrisbiiError

This commit is contained in:
Colin Maudry
2026-06-25 22:34:29 +02:00
parent 1bd15f627f
commit 5bd7029066
+10 -7
View File
@@ -25,13 +25,16 @@ def _base_url() -> str:
def _call(method: str, path: str, json: dict | None = None) -> dict: def _call(method: str, path: str, json: dict | None = None) -> dict:
resp = httpx.request( try:
method, resp = httpx.request(
f"{_base_url()}{path}", method,
auth=(_api_key(), ""), f"{_base_url()}{path}",
json=json, auth=(_api_key(), ""),
timeout=_TIMEOUT, json=json,
) timeout=_TIMEOUT,
)
except httpx.RequestError as exc:
raise FrisbiiError(0, str(exc)) from exc
if resp.status_code >= 400: if resp.status_code >= 400:
raise FrisbiiError(resp.status_code, resp.text) raise FrisbiiError(resp.status_code, resp.text)
return resp.json() return resp.json()