diff --git a/app/api/v1/chat.py b/app/api/v1/chat.py index 9e612a8..87460e5 100644 --- a/app/api/v1/chat.py +++ b/app/api/v1/chat.py @@ -62,7 +62,7 @@ async def chat_completions( return result except GrokApiException as e: - logger.error(f"[Chat] Grok API错误: {str(e)}", extra={"details": e.details}) + logger.error(f"[Chat] Grok API错误: {str(e)} - 详情: {e.details}") raise HTTPException( status_code=500, detail={ diff --git a/app/core/exception.py b/app/core/exception.py index 52ac613..a5c179b 100644 --- a/app/core/exception.py +++ b/app/core/exception.py @@ -101,7 +101,7 @@ async def grok_api_exception_handler(_: Request, exc: GrokApiException) -> JSONR ) -async def global_exception_handler(_: Request) -> JSONResponse: +async def global_exception_handler(_: Request, exc: Exception) -> JSONResponse: """处理未捕获异常""" return JSONResponse( status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,