fix: 错误系统重构、消除静默吞错、update 修复、文档同步

This commit is contained in:
2026-06-10 21:04:34 +08:00
parent 4d206f39cc
commit 2552412f77
12 changed files with 99 additions and 55 deletions

View File

@@ -38,7 +38,7 @@ describe("mapError", () => {
const err = new Error("missing required args for command `plan`");
const result = mapError(err);
expect(result).toBeInstanceOf(UsageError);
expect(result.message).toBe("命令 'plan' 缺少必填参数");
expect(result.message).toBe(`命令"plan"缺少必填参数`);
expect(result.usage).toBe(`${DEFAULT_PREFIX} plan <change-name>`);
expect(result.hint).toContain(`${DEFAULT_PREFIX} help plan`);
});
@@ -47,7 +47,8 @@ describe("mapError", () => {
const err = new Error("something unexpected");
const result = mapError(err);
expect(result).toBeInstanceOf(InternalError);
expect(result.message).toBe("发生了未预期的错误");
expect(result.message).toContain("发生了未预期的错误");
expect(result.message).toContain("something unexpected");
});
it("非 Error 类型转为 InternalError", () => {

View File

@@ -90,12 +90,11 @@ stages:
expect(config.stages.archive).toBeDefined();
});
it("YAML 解析错误时返回默认配置", async () => {
it("YAML 解析错误时抛出 ConfigError", async () => {
const runeDir = join(TMP_DIR, ".rune");
await mkdir(runeDir, { recursive: true });
await writeFile(join(runeDir, "config.yaml"), `stages: [invalid yaml {{{`);
const config = await loadConfig(TMP_DIR);
expect(config.stages.discuss).toBeDefined();
expect(loadConfig(TMP_DIR)).rejects.toThrow(ConfigError);
});
});