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

    Function 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.

      Parameters

      Returns Promise<void>

      A promise that resolves once the write settles.

      await recordError({ source: "react", message: "render failed" });
      
      export async function recordError(entry: Omit<CapturedError, 'ts'>): Promise<void> {
      writeChain = writeChain.then(async () => {
      try {
      const current = await getRecentErrors();
      const next = [...current, { ...entry, ts: Date.now() }].slice(-MAX_ERRORS);
      await cstorage.session.set({ [STORAGE_KEY]: next });
      } catch {
      // Best-effort: a diagnostic buffer must never surface its own failures.
      }
      });
      return writeChain;
      }