Error report rules

@interlace/ui — the pure rules of error reporting: a typed report, a flood counted not repeated, a redaction hook, restore from untrusted storage, text for a diagnostics screen. No DOM, no network, no storage library.

feedbackserverlibv1.0.2
Visual examples + interactive variants
View Error report rules 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-model.json
With the @interlace alias
npx shadcn@latest add @interlace/error-report-model

History

This component is at v1.0.2, 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.02 entries

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

  • Changedpatch

    The error-report rules are now held by tests at a mutation score of 100 percent. Two helpers lost a branch that could not change the result (trimStack, the stored-row count), the device log awaits save through Promise.resolve instead of a hand-written thenable check, and an id, the stack length option and the order of kept reports now have tests of their own. No behaviour change.

Import

13 named exports — pull the parts you need.

Public API
import { DEFAULT_ERROR_FALLBACK_LABELS, REDACTION_FAILED, createErrorLog, defaultErrorLog, extendErrorLog, formatReports, parseReports, referenceOf, resolveFallbackLabels, restoreRecent, subscribeErrors, toReport, wrapNativeHandler } from '@/lib/error-report-model';

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-model.ts once installed.

314 lines · TypeScript
import {
  DEFAULT_COALESCE_MS,
  DEFAULT_MAX,
  DEFAULT_MAX_MESSAGE,
  DEFAULT_MAX_STACK_LINES,
  buildReport,
  createCoreLog,
  defaultMakeId,
  trimMessage,
  trimStack,
  type ErrorLog,
  type ErrorLogCore,
  type ErrorLogOptions,
  type ErrorReport,
  type Limits,
} from '@/lib/error-report-log-model';

// @interlace/error-report-model v1.0.2 — Interlace design system.
// Docs, props and live preview: https://ds.interlace.tools/c/error-report-model
// What changed since: https://ds.interlace.tools/c/error-report-model#history

…294 more lines…

Registry JSON

The raw registry record — what the shadcn CLI fetches.