refactor: 统一错误处理机制

- 引入 ConfigError/TemplateError/BuildError/FileError 与 wrapAsyncError,统一错误输出
- generator 入口接入 wrapAsyncError,确保命令行执行路径一致
- 兜底逻辑使用 instanceof,保留 BuildError/TemplateError 上下文信息
- 合并格式化提交(仅缩进/换行调整)
This commit is contained in:
rbetree
2026-01-16 02:25:03 +08:00
parent 1a90f8fbe3
commit 89c1c0330b
31 changed files with 313 additions and 89 deletions

View File

@@ -13,4 +13,3 @@ test('P1-5404.html 回跳应将 /<id> 转为 ?page=<id>(并支持仓库前
assert.ok(html.includes('segments.length === 2'), '应支持仓库站点 /<repo>/<id>');
assert.ok(html.includes('l.replace(target)'), '应使用 location.replace 执行回跳');
});

View File

@@ -20,9 +20,7 @@ test('P1-7页面内不应注入整站 configJSON应仅保留扩展元信
const config = loadConfig();
const html = generateHTML(config);
const match = html.match(
/<script id="menav-config-data"[^>]*>([\s\S]*?)<\/script>/m
);
const match = html.match(/<script id="menav-config-data"[^>]*>([\s\S]*?)<\/script>/m);
assert.ok(match, '应输出 menav-config-data 脚本块');
const raw = String(match[1] || '').trim();
@@ -53,4 +51,3 @@ test('P1-7页面内不应注入整站 configJSON应仅保留扩展元信
assert.ok(!/"sites"\s*:/.test(raw), '不应包含 sites 字段');
});
});