INNER CODE UNIT · Python
_api_proxy_error_handler
speaches-ai/speaches · src/speaches/main.py:136
async def _api_proxy_error_handler(_request: Request, exc: APIProxyError) -> JSONResponse:
error_id = str(uuid.uuid4())
logger.exception(f"[{{error_id}}] {exc.message}")
content = {
"detail": exc.message,
"hint": exc.hint,
"suggested_fixes": exc.suggestions,
"error_id": error_id,
}
# HACK: replace with something else
log_level = os.getenv("SPEACHES_LOG_LEVEL", "INFO").upper()
if log_level == "DEBUG" and exc.debug:
content["debug"] = exc.debug
return JSONResponse(status_code=exc.status_code, content=content)
@app.exception_handler(StarletteHTTPException)
async def _custom_http_exception_handler(request: Request, exc: HTTPException) -> Response: