mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-22 15:06:57 +00:00
Co-authored-by: roboclaw-bot <309084314+roboclaw-bot@users.noreply.github.com> Co-authored-by: RomneyDa <6581799+RomneyDa@users.noreply.github.com>
26 lines
1 KiB
TypeScript
26 lines
1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { formatErrorMessageWithCauses } from "../../scripts/lib/error-format.mts";
|
|
|
|
describe("formatErrorMessageWithCauses", () => {
|
|
it("renders the nested transport cause attached by a read owner", () => {
|
|
const transport = new Error("getaddrinfo ENOTFOUND registry.npmjs.org");
|
|
const readback = new TypeError("fetch failed", { cause: transport });
|
|
const failure = new Error(
|
|
"https://registry.npmjs.org/openclaw: readback failed. Retry readback, not publication.",
|
|
{ cause: readback },
|
|
);
|
|
|
|
expect(formatErrorMessageWithCauses(failure)).toBe(
|
|
"https://registry.npmjs.org/openclaw: readback failed. Retry readback, not publication.\n" +
|
|
"Caused by: fetch failed\n" +
|
|
"Caused by: getaddrinfo ENOTFOUND registry.npmjs.org",
|
|
);
|
|
});
|
|
|
|
it("bounds cyclic cause chains", () => {
|
|
const failure = new Error("outer");
|
|
failure.cause = failure;
|
|
|
|
expect(formatErrorMessageWithCauses(failure)).toBe("outer");
|
|
});
|
|
});
|