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

    Module helpers/errorBuffer

    Bug reporting - Helpers

    ErrorSource

    Where a captured error originated: a global window/worker hook, an unhandled promise rejection, React's error hooks, or an aggregated supplier-search failure.

    CapturedError

    A single captured exception, trimmed to what a bug report needs.

    Functions

    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.

    getRecentErrors

    Reads the current ring buffer from session storage, tolerating a missing or malformed value by returning an empty list.

    recordError

    Appends one exception to the ring buffer, trimming to the most recent MAX_ERRORS. Never throws — a failure to record must not cascade into the code path that raised the original error. Writes are serialized so concurrent captures don't clobber each other.

    recordException

    Records an arbitrary thrown value into the ring buffer, folding its cause chain (and any AggregateError sub-errors) into the stored stack. Convenience over recordError for callers that hold the raw error.

    installErrorCapture

    Registers global error and unhandledrejection listeners that push captured exceptions into the ring buffer. Idempotent, and safe in both window and service-worker contexts (both expose self with addEventListener).