From e511b149330ca42dd36dc1b8cbfc1ecc463651f2 Mon Sep 17 00:00:00 2001 From: lanceyq <1982376970@qq.com> Date: Thu, 5 Mar 2026 11:06:46 +0800 Subject: [PATCH] [fix] Deleting the default scene results in a 400 status code. A unified language pop-up prompt is displayed. --- api/app/controllers/ontology_controller.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/api/app/controllers/ontology_controller.py b/api/app/controllers/ontology_controller.py index 42d4bee0..c892b013 100644 --- a/api/app/controllers/ontology_controller.py +++ b/api/app/controllers/ontology_controller.py @@ -523,10 +523,9 @@ async def delete_scene( f"尝试删除系统默认场景: user_id={current_user.id}, " f"scene_id={scene_id}, scene_name={scene.scene_name}" ) - return fail( - BizCode.BAD_REQUEST, - "系统默认场景不可删除", - "该场景为系统预设场景,不允许删除" + raise HTTPException( + status_code=400, + detail="SYSTEM_DEFAULT_SCENE_CANNOT_DELETE" ) # 创建OntologyService实例 @@ -552,6 +551,9 @@ async def delete_scene( return success(data={"deleted": success_flag}, msg="场景删除成功") + except HTTPException: + raise + except ValueError as e: api_logger.warning(f"Validation error in scene deletion: {str(e)}") return fail(BizCode.BAD_REQUEST, "请求参数无效", str(e))