fix(后端): 区分 T+ 连接文件的缺失与字段错误
原先 OSError、ValueError、ValidationError 统一归并为「不可用 或字段不正确」,文件不存在和字段写错无法区分,排障困难。 拆分为两条消息分别指示故障类别,仍不回显文件内容与路径。 Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
1 parent
013d6e7a74
commit
1b074576fe
1 file changed
+5
-2
@@ -43,8 +43,11 @@ def resolve_tplus_settings(settings: Settings) -> Settings:
|
|||||||
config = _ConnectionFile.model_validate(
|
config = _ConnectionFile.model_validate(
|
||||||
json.loads(path.read_text(encoding="utf-8-sig"))
|
json.loads(path.read_text(encoding="utf-8-sig"))
|
||||||
)
|
)
|
||||||
except (OSError, ValueError, ValidationError):
|
except OSError:
|
||||||
raise RuntimeError("T+ 只读连接文件不可用或字段不正确") from None
|
# 消息只区分故障类别,不回显路径内容;路径本身可在应用配置中核对。
|
||||||
|
raise RuntimeError("T+ 只读连接文件不存在或不可读") from None
|
||||||
|
except (ValueError, ValidationError):
|
||||||
|
raise RuntimeError("T+ 只读连接文件字段不正确") from None
|
||||||
values = {
|
values = {
|
||||||
"t_plus_" + key: getattr(config, key) for key in ("host", "port", "database", "user")
|
"t_plus_" + key: getattr(config, key) for key in ("host", "port", "database", "user")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user