errorBoundary()
Wrap a subtree with a fallback that renders when something inside throws. Prefer this over a hand-rolled try/catch in a component setup.
Signature
Section titled “Signature”function errorBoundary( fallback: (error: Error, retry: () => void) => WhisqNode, child: () => WhisqNode,): WhisqNodeParameters
Section titled “Parameters”| Param | Type | Description |
|---|---|---|
fallback | (error: Error, retry: () => void) => WhisqNode | Rendered when the wrapped subtree throws. retry re-runs child |
child | () => WhisqNode | The protected subtree, wrapped in a thunk so retry can re-invoke it |
Examples
Section titled “Examples”import { errorBoundary, div, p, button } from "@whisq/core";
errorBoundary( (error, retry) => div({ class: "error-boundary" }, p(`Something went wrong: ${error.message}`), button({ onclick: retry }, "Try again"), ), () => RiskyComponent({}),);See Advanced → Error Boundaries for granular wrapping, error reporting, and how the primitive composes with resource().