from fastapi import Request, status
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse
from utils.response import resp_400
from fastapi.encoders import jsonable_encoder
 
async def validationExceptionHandler(request: Request, exc: RequestValidationError):
    """ 自定义参数验证异常错误"""    
    errMsg = ""
    for error in exc.errors():
        errMsg += ".".join(error.get("loc")) + ":" + error.get("msg") + ";"
 
    return resp_400( data=[], message = errMsg) #JSONResponse(status_code=status.HTTP_200_OK, content=jsonable_encoder(resp_400( message = errMsg)))