update
This commit is contained in:
parent
804584550e
commit
c7fcfc7443
@ -8,6 +8,7 @@ from app.core.response import error_response
|
||||
from fastapi import HTTPException
|
||||
from app.middleware.request_logger import RequestLoggerMiddleware
|
||||
from app.core.response import CustomJSONResponse
|
||||
import logging
|
||||
|
||||
# 创建数据库表
|
||||
Base.metadata.create_all(bind=engine)
|
||||
@ -66,6 +67,7 @@ async def health_check():
|
||||
|
||||
@app.exception_handler(RequestValidationError)
|
||||
async def validation_exception_handler(request, exc):
|
||||
logging.exception(f"请求参数错误: {str(exc)}")
|
||||
return CustomJSONResponse(
|
||||
status_code=400,
|
||||
content=error_response(
|
||||
@ -76,6 +78,7 @@ async def validation_exception_handler(request, exc):
|
||||
|
||||
@app.exception_handler(HTTPException)
|
||||
async def http_exception_handler(request, exc):
|
||||
logging.exception(f"HTTP异常: {str(exc)}")
|
||||
return CustomJSONResponse(
|
||||
status_code=exc.status_code,
|
||||
content=error_response(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user