Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/mutation-scopes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"scopes": {
"kernel": {
"mutate": "src/kernel/**/*.ts",
"break": 71
"break": 95
},
"tools": {
"mutate": [
Expand Down Expand Up @@ -38,7 +38,7 @@
},
"runtime": {
"mutate": "src/runtime/**/*.ts",
"break": 67
"break": 90
},
"tools-claude": {
"mutate": "src/contexts/tools/domain/profiles/claude/**/*.ts",
Expand Down
32 changes: 32 additions & 0 deletions cli/tests/kernel/describe-error.unit.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, it } from "vitest";
import { describeError, errorMessage } from "../../src/kernel/describe-error.js";

describe("describeError", () => {
it("answers the code of a filesystem failure", () => {
expect(describeError(Object.assign(new Error("open failed"), { code: "ENOENT" }))).toBe(
"ENOENT"
);
});

it("answers the message when the code is not a string", () => {
expect(describeError(Object.assign(new Error("open failed"), { code: 2 }))).toBe("open failed");
});

it("answers the message of an Error carrying no code", () => {
expect(describeError(new SyntaxError("Unexpected token"))).toBe("Unexpected token");
});

it("stringifies a thrown value that is not an Error, whatever fields it carries", () => {
expect(describeError({ code: "ENOENT" })).toBe("[object Object]");
});
});

describe("errorMessage", () => {
it("answers an Error's message", () => {
expect(errorMessage(new Error("bad json"))).toBe("bad json");
});

it("stringifies a thrown value that is not an Error", () => {
expect(errorMessage(42)).toBe("42");
});
});
Loading