Wrap les erreurs httpx du client Frisbii en FrisbiiError
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user