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

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

      Returns void

      Nothing.

      installErrorCapture(); // call once per context, before the app runs
      
      export function installErrorCapture(): void {
      if (captureInstalled) return;
      if (typeof self === 'undefined' || typeof self.addEventListener !== 'function') return;
      captureInstalled = true;

      self.addEventListener('error', (event: ErrorEvent) => {
      const described = event.error ? describeError(event.error) : { message: event.message };
      void recordError({ source: 'window', ...described });
      });

      self.addEventListener('unhandledrejection', (event: PromiseRejectionEvent) => {
      void recordError({ source: 'unhandledrejection', ...describeError(event.reason) });
      });
      }