跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

error-message.test.mjs

24 行 · 1.6 KB历史下载
1import test from "node:test";
2import assert from "node:assert/strict";
3import { httpErrorMessage, connectionErrorMessage, nativeFailureMessage } from "./error-message.mjs";
4
5test("HTTP failures name the operation and avoid upstream HTML or opaque runtime output", () => {
6 for (const [status, reason] of [[401, "登录会话"], [409, "操作"], [413, "大小"], [503, "尚未就绪"], [504, "超时"]]) {
7 const message = httpErrorMessage("/environment/resources", status, "<html>token=private</html>", "text/html");
8 assert.match(message, /资源配置/);
9 assert.ok(message.includes(reason));
10 assert.ok(!message.includes("private"));
11 }
12 const specific = "上传窗口已关闭,请重新点击网页上传按钮";
13 assert.equal(httpErrorMessage("/input/files", 409, specific, "text/plain; charset=utf-8"), specific);
14 assert.match(connectionErrorMessage("/input/files"), /传递文件.*连接已中断.*核对结果/);
15 assert.match(httpErrorMessage("/settings", 503, "", "", "POST"), /无法确认设置是否已保存.*核对设置/);
16});
17
18test("native errors retain precise rules and explain opaque failures in context", () => {
19 assert.match(nativeFailureMessage("exportDiagnostics", "Native operation timeout"), /导出诊断包.*超时/);
20 assert.match(nativeFailureMessage("uploadHostFiles", "operation failed token=private"), /上传本机文件失败.*可识别的原因/);
21 assert.ok(!nativeFailureMessage("uploadHostFiles", "operation failed token=private").includes("private"));
22 const rule = "请选择本机项目中的文件";
23 assert.equal(nativeFailureMessage("uploadHostFiles", rule), rule);
24});