reportError

@interlace/ui — `reportError(error, where)`, one function every caught failure goes through, with a pluggable reporter, a device-only crash log and global handlers. Sends nothing unless you set a reporter.

feedbackserverlibv1.0.1
Visual examples + interactive variants
View reportError on Storybook
No embeddable story for this item yet.
→

Install

Two equivalent paths — the URL works in any shadcn-CLI setup; the alias works once you've registered @interlace in your components.json.

Via shadcn URL
npx shadcn@latest add https://ds.interlace.tools/r/error-report.json
With the @interlace alias
npx shadcn@latest add @interlace/error-report

History

This component is at v1.0.1, first shipped in @interlace/ui 2.3.0. The version is stamped as a banner into the file the install writes, so the copy in your tree says which one you have — compare it with the number above before deciding whether to re-run the install.

@interlace/ui 2.4.01 entry

  • Addedminor

    reportError no longer costs a page the whole error log. The small half (the report, the ring of recent reports, the flood rule, installGlobalHandlers) is its own entry, @interlace/ui/error-report-core, 992 B gzipped against 1,412 B before; listeners, restore, installErrorLog, formatReports and the fallback copy stay in @interlace/ui/error-report-model, imported only where used. @interlace/ui/error-report still exports every name it did. createErrorLog is unchanged; extendErrorLog and createCoreLog are new. A test bundles the first-load path and fails above 1,000 B gzipped. No new dependency for consumers, no network call.

@interlace/ui 2.3.01 entry

  • Addedminor

    Nothing fails silently, and a crash never leaves a blank screen. reportError(error, where) is one function every caught failure goes through: it builds a typed report (the place you name, a message and a stack, redacted then trimmed, a count, a random id), keeps the last 25 in memory, counts a flood of the same failure in one second as one report, and hands each to a pluggable reporter. The default reporter writes one development console line and sends nothing; a crash service is one setReporter call, and a reporter that throws, or reports from inside itself, is contained. installErrorLog(store) keeps the last reports on the device in an adapter the app passes (load and save), so a problem from an earlier session can be read on a diagnostics screen (useRecentErrors(), formatReports()); a store that fails is silent by design. installGlobalHandlers() reports error and unhandledrejection in the browser; installNativeErrorHandler() does the same for React Native and then calls the platform's own handler, so a production crash still crashes. ErrorFallback is what a screen shows when it crashes: plain words, Try again, a way out, a short reference to quote; it reports once on mount, moves focus to its title, is announced as an alert, never shows the message or the stack, and takes the { error, reset } of Next and Remix or the { error, retry } of Expo Router without importing a router. SectionBoundary gains an optional onError(error, name). No dependency, no network call, no personal data.

Accessibility

Every story for this component is rendered headlessly and checked with axe-core (wcag2aa, wcag22aa, best-practice, ACT) on every PR. That gate has no continue-on-error, so what ships has zero known violations.

What follows is what static analysis can see. Axe cannot press a key and never sees an overlay open, so the operable-without-a-mouse claim lives in Behavior instead, where the keyboard path is replayed step by step.

Focus + keyboard behaviour
Native element semantics — no interaction layer to get wrong.
Focus ring (WCAG 2.2 SC 2.4.13)
Not focusable — no focus indicator required.
Reduced motion
No animation to gate.
ARIA in the source
None — semantics come from the element or the Base UI primitive rather than hand-written ARIA.

Dependencies

Base UI primitive
Native / no Base UI dependency
Lucide icons
none
NPM dependencies
none

Source

The full implementation — lib/error-report.ts once installed.

31 lines · TypeScript
export * from '@/lib/error-report-core';
export * from '@/lib/error-report-model';

/**
 * @interlace/ui: `reportError`, the one function every caught failure goes through.
 *
 *   import { reportError } from '@interlace/ui/error-report';
 *
 *   try { await save(draft); } catch (error) { reportError(error, 'checkout: save'); }
 *
 * It builds a typed report, keeps the last few in memory, and hands each to a reporter. The
 * default reporter is a development console line and nothing else: no report leaves the device
 * unless the app calls `setReporter` with a function of its own. Nothing here calls `fetch`.
 *
 *   setReporter((report) => crashService.capture(report));   // the whole vendor seam
 *   void installErrorLog(store);                              // keep the last reports on the device
 *   installGlobalHandlers();                                  // browser: error + unhandledrejection
 *
 * This file is every name in one import, and so it is the heaviest way in. It stays so that
 * `import { ... } from '@interlace/ui/error-report'` keeps working. For a first page load import

…11 more lines…

Registry JSON

The raw registry record — what the shadcn CLI fetches.