Error Explainer

Error Explainer is a copy-paste React component that stops paid twice after a payment timeout error before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/error-explainer
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsPaid twice after a payment timeout error

Was this component page useful?

How do I install Error Explainer?

pnpm dlx shadcn@latest add @bollard/error-explainer

The files land in your project. They're yours to edit.

How do I use Error Explainer in React?

error-explainer-usage.tsx
import { ErrorExplainer } from "@/components/ui/error-explainer"

<ErrorExplainer
  key="payment"
  code={504}
  explanation={{ title: "We didn't hear back about your payment of ₹2,499" }}
  message="Gateway Timeout"
  details={stack}
  referenceId="PAY-7Q4K-2M9X"
  occurredAt={occurredAt}
  idempotent={false}
  onCheckStatus={() => setNote("Checked: the payment went through. Order #48213 is confirmed, nothing to retry.")}
  onRetry={() => Promise.reject(new Error("still timing out"))}
  onContact={() => setNote("Opening support with the reference attached…")}
/>

What input mistakes does Error Explainer catch?

  • Raw codes with no explanation, mapped through your catalog
  • Retrying before Retry-After allows
  • Retrying a non-idempotent request after an ambiguous timeout (offers Check status first)
  • Errors that keep failing, with a contact option after maxRetries

What props does Error Explainer accept?

ErrorExplainer props
PropTypeDefault
code* (required)

Error code: an HTTP status, "network", "timeout" or your own key.

string | number—
message

The raw message from the system, shown under Technical details.

string—
explanation

Overrides for the catalog entry (title, meaning, cause, action...).

Partial<ErrorExplanation>—
catalog

Your own catalog of codes.

Record<string, ErrorExplanation>—
referenceId

Request or trace ID support can search for.

string—
occurredAt

When it failed.

Date | number | string—
details

Stack trace or response body, hidden until asked for.

string—
onRetry

Retries the failed action. May return a Promise; a rejection counts as another failure.

() => void | Promise<unknown>—
retryAfter

Seconds to wait before retrying (from a Retry-After header).

number0
idempotent

False when repeating the action could do it twice (a payment, a send). Ambiguous failures then say to check first.

booleantrue
onCheckStatus

Looks up whether the action actually went through, offered first when a retry might duplicate it.

() => void—
onFix

Runs the "fix" action (sign in, open settings...).

() => void—
onContact

Opens support.

() => void—
maxRetries

Failed retries after which support is suggested instead.

number3
causeLabel

Templates: `{seconds}` and `{count}` are filled in.

string"Likely cause:"
retryLabel

Retry button text.

string"Try again"
retryAnywayLabel

Text for retrying despite an ambiguous outcome.

string"Retry anyway"
waitLabel

Text shown while waiting for Retry-After.

string"Try again in {seconds}s"
checkLabel

Text for the check-status button.

string"Check status"
contactLabel

Text for the contact-support button.

string"Contact support"
ambiguousText

Warning that the request may already have gone through.

string"This may have gone through before the error. Check first…
stillFailingText

Shown after repeated failures.

string"Still failing after {count} tries."
referenceLabel

Label for the support reference.

string"Reference"
copyLabel

Text for the copy-reference button.

string"Copy reference for support"
copiedLabel

Shown after copying the reference.

string"Copied"
copyText

Visible text of the copy button (`copyLabel` is its accessible name).

string"Copy"
fixLabel

Button text for a "fix" action without its own `actionLabel`.

string"Fix it"
detailsLabel

Text for the technical-details toggle.

string"Technical details"

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Error Explainer accessible?

  • The error is announced with role="alert"
  • Waiting and status changes are aria-live="polite"
  • Actions are buttons with visible text; icons are aria-hidden

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Make retried operations idempotent on the server and expose a status endpoint for ambiguous outcomes.

  • Explanations come from the catalog or explanation you pass
  • Whether a retry is safe depends on the `idempotent` flag you set

What expensive mistakes does Error Explainer stop?

Paid twice after a payment timeout error

Also known as

error message · error state · 500 · timeout · retry · support reference · payment failed · error boundary

Field type

What dependencies does Error Explainer require?

Error Explainer facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameError Explainer
Registry identifier@bollard/error-explainer
Install commandnpx shadcn@latest add @bollard/error-explainer
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Error Explainer

How does Error Explainer prevent financial transaction errors?

Error Explainer prevents paid twice after a payment timeout error. Blocks Raw codes with no explanation, mapped through your catalog, Retrying before Retry-After allows, Retrying a non-idempotent request after an ambiguous timeout (offers Check status first), Errors that keep failing, with a contact option after maxRetries before processing. Limitation: apply idempotency keys for error-explainer.

How do I install error-explainer with shadcn?

Run `npx shadcn@latest add @bollard/error-explainer`. Sources added: registry/default/error-explainer/error-explainer.tsx. Package requirements: lucide-react.

What props customize Error Explainer?

Error Explainer accepts `code`, `message`, `explanation`, `catalog`, `referenceId`. Configures error message, error state, 500 behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of error-explainer?

Explanations come from the catalog or explanation you pass. Whether a retry is safe depends on the `idempotent` flag you set Server requirement: Make retried operations idempotent on the server and expose a status endpoint for ambiguous outcomes.

How does Error Explainer meet accessibility guidelines?

The error is announced with role="alert". Waiting and status changes are aria-live="polite". Actions are buttons with visible text; icons are aria-hidden. Minimizes errors: error code meaningless, something went wrong.

Which components pair with Error Explainer?