AI-News/backend/app/api/errors/http_error.py

8 lines
277 B
Python
Raw Normal View History

2025-12-04 10:04:21 +08:00
from fastapi import HTTPException
from starlette.requests import Request
from starlette.responses import JSONResponse
async def http_error_handler(_: Request, exc: HTTPException) -> JSONResponse:
return JSONResponse({"errors": [exc.detail]}, status_code=exc.status_code)