[fix]:[FL-190][系统接口中的stacktrace信息不要直接展示到页面给用户看]
- 后端:在 exception_handlers.py 添加文档注释,明确说明 stacktrace 字段仅供开发调试使用 - 前端:在 api.ts 添加 ApiErrorResponse 类型定义和文档注释,明确 readApiError 函数只提取 detail 字段展示给用户 - stacktrace 在 debug 模式下会返回给浏览器(可在开发者工具中查看),但前端不会展示到页面上 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -6,6 +6,14 @@ from .config import get_settings
|
||||
|
||||
|
||||
async def global_exception_handler(request: Request, exc: Exception) -> JSONResponse:
|
||||
"""
|
||||
全局异常处理器
|
||||
|
||||
返回的错误响应包含:
|
||||
- detail: 错误描述信息(面向用户,前端会展示此字段)
|
||||
- type: 异常类型名称
|
||||
- stacktrace: 调用栈信息(仅在debug模式下返回,仅供开发人员调试使用,前端不应展示给用户)
|
||||
"""
|
||||
settings = get_settings()
|
||||
|
||||
error_response = {
|
||||
@@ -13,6 +21,7 @@ async def global_exception_handler(request: Request, exc: Exception) -> JSONResp
|
||||
"type": type(exc).__name__,
|
||||
}
|
||||
|
||||
# stacktrace 仅用于开发调试,不应直接展示到页面给用户看
|
||||
if settings.debug_mode:
|
||||
error_response["stacktrace"] = traceback.format_exc()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user