MCPcopy Create free account
hub / github.com/OpenPipe/ART / log_http_errors

Function log_http_errors

src/art/utils/log_http_errors.py:6–22  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

4
5
6def log_http_errors(func):
7 @wraps(func)
8 async def wrapper(*args, **kwargs):
9 try:
10 return await func(*args, **kwargs)
11 except httpx.HTTPStatusError as e:
12 # raise a new exception with the status code, url, and "detail" key if it exists
13 try:
14 detail = e.response.json().get("detail", None)
15 except Exception:
16 # if we can't parse the response as json, just raise the original exception
17 raise e
18 raise Exception(
19 f"[HTTP {e.response.status_code}] {e.request.url} {detail}"
20 ) from e
21
22 return wrapper

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected