INNER CODE UNIT · Python
global_exception_handler
KatrielMoses/voidaccess · api/main.py:378
async def global_exception_handler(request: Request, exc: Exception):
# Public error, private log: log the full exception (message + traceback)
# server-side tagged with a correlation ID, and return only a generic
# message + that same ID to the client. Never leak raw exception text.
correlation_id = log_exception(exc, request=request)
return JSONResponse(
status_code=500,
content=safe_error_body(correlation_id),
)
# ---------------------------------------------------------------------------
# Global rate limit middleware (100/minute for all API routes)
# ---------------------------------------------------------------------------
@app.middleware("http")
async def global_rate_limit_middleware(request: Request, call_next: Callable):