neotwin-api / core /exceptions.py
1qwsd's picture
deploy: NeoTwin backend v1.0 - FastAPI + Gemini AI
d1a1edf
raw
history blame contribute delete
518 Bytes
"""Custom exception handlers"""
from fastapi import Request, HTTPException
from fastapi.responses import JSONResponse
async def http_exception_handler(request: Request, exc: HTTPException):
return JSONResponse(
status_code=exc.status_code,
content={"error": exc.detail, "status": exc.status_code}
)
async def general_exception_handler(request: Request, exc: Exception):
return JSONResponse(
status_code=500,
content={"error": "Internal server error", "status": 500}
)