[FWA-5] Home Create and List
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
from collections.abc import AsyncGenerator
|
||||
from contextlib import asynccontextmanager
|
||||
from fastapi import FastAPI, Request, HTTPException
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.middleware.gzip import GZipMiddleware
|
||||
@ -70,6 +71,11 @@ async def unicorn_exception_handler(request: Request, exc: HTTPException):
|
||||
content={"status": exc.status_code, "data": exc.detail},
|
||||
)
|
||||
|
||||
@app.exception_handler(RequestValidationError)
|
||||
async def validation_exception_handler(request: Request, exc: RequestValidationError):
|
||||
print(exc)
|
||||
return JSONResponse(status_code=422, content={"status": 422, "data": str(exc)})
|
||||
|
||||
def api_routers():
|
||||
app.include_router(router)
|
||||
|
||||
|
Reference in New Issue
Block a user