The error to render.
The stack (or name: message) plus each Caused by: link.
formatErrorChain(new Error("outer", { cause: new Error("inner") }));
// => "Error: outer\n…\nCaused by: Error: inner\n…"
export function formatErrorChain(error: Error): string {
return renderErrorChain(error, 0);
}
Renders an
Errortogether with itscausechain (ES2022) into a single stack string, so a wrapped error's root cause isn't lost. Non-Errorcauses are stringified; the walk is depth-limited to guard against cyclic or pathologically deep chains.