From 1b074576fe3a7d5f65564d219ea22386be8b4568 Mon Sep 17 00:00:00 2001 From: liuwenxin <1009266660@qq.com> Date: Fri, 30 Oct 2026 09:58:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=90=8E=E7=AB=AF):=20=E5=8C=BA=E5=88=86?= =?UTF-8?q?=20T+=20=E8=BF=9E=E6=8E=A5=E6=96=87=E4=BB=B6=E7=9A=84=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=E4=B8=8E=E5=AD=97=E6=AE=B5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原先 OSError、ValueError、ValidationError 统一归并为「不可用 或字段不正确」,文件不存在和字段写错无法区分,排障困难。 拆分为两条消息分别指示故障类别,仍不回显文件内容与路径。 Co-Authored-By: Claude Code --- backend/app/core/tplus_db.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/app/core/tplus_db.py b/backend/app/core/tplus_db.py index 696be1a..1073ee2 100644 --- a/backend/app/core/tplus_db.py +++ b/backend/app/core/tplus_db.py @@ -43,8 +43,11 @@ def resolve_tplus_settings(settings: Settings) -> Settings: config = _ConnectionFile.model_validate( json.loads(path.read_text(encoding="utf-8-sig")) ) - except (OSError, ValueError, ValidationError): - raise RuntimeError("T+ 只读连接文件不可用或字段不正确") from None + except OSError: + # 消息只区分故障类别,不回显路径内容;路径本身可在应用配置中核对。 + raise RuntimeError("T+ 只读连接文件不存在或不可读") from None + except (ValueError, ValidationError): + raise RuntimeError("T+ 只读连接文件字段不正确") from None values = { "t_plus_" + key: getattr(config, key) for key in ("host", "port", "database", "user") }