fix(acp-core): never return undefined from stringifyNonErrorCause (#9… · openclaw/openclaw@599294b
ly-wang19
·
2026-06-24
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Error-format helper tests cover the non-Error cause stringifier contract. |
| 2 | +import { describe, expect, it } from "vitest"; |
| 3 | +import { stringifyNonErrorCause } from "./error-format.js"; |
| 4 | + |
| 5 | +describe("stringifyNonErrorCause", () => { |
| 6 | +it("returns a string for values JSON.stringify serializes to undefined", () => { |
| 7 | +// JSON.stringify(fn|symbol|undefined) is undefined; the `string`-typed helper must not leak it. |
| 8 | +expect(stringifyNonErrorCause(() => {})).toBe("[object Function]"); |
| 9 | +expect(stringifyNonErrorCause(Symbol("x"))).toBe("[object Symbol]"); |
| 10 | +expect(stringifyNonErrorCause(undefined)).toBe("[object Undefined]"); |
| 11 | +}); |
| 12 | + |
| 13 | +it("stringifies ordinary scalar and object causes", () => { |
| 14 | +expect(stringifyNonErrorCause({ a: 1 })).toBe('{"a":1}'); |
| 15 | +expect(stringifyNonErrorCause("hi")).toBe("hi"); |
| 16 | +expect(stringifyNonErrorCause(42)).toBe("42"); |
| 17 | +expect(stringifyNonErrorCause(null)).toBe("null"); |
| 18 | +}); |
| 19 | +}); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。