ChemPal Documentation - v1.7.0
    Preparing search index...

    Function formatErrorChain

    • Renders an Error together with its cause chain (ES2022) into a single stack string, so a wrapped error's root cause isn't lost. Non-Error causes are stringified; the walk is depth-limited to guard against cyclic or pathologically deep chains.

      Parameters

      • error: Error

        The error to render.

      Returns string

      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);
      }