Advanced / JSX Component Primitives

createErrorBoundary

Lower-level primitive that backs the <Errored> flow control. Catches thrown errors inside fn and invokes fallback(error, reset) instead. error is an accessor for the latest captured error; reset() recomputes the failing sources so the boundary can attempt to recover.

App code should use <Errored fallback={...}> instead — reach for this only when authoring custom boundary components.


Import

import { createErrorBoundary } from "solid-js";

Type signature

function createErrorBoundary<U>(
fn: () => any,
fallback: (error: Accessor<unknown>, reset: () => void) => U
);

Examples

// Custom boundary that wraps the primitive and adds telemetry.
function TracedErrored(props: {
fallback: (e: () => unknown) => JSX.Element;
children: JSX.Element;
}) {
return createErrorBoundary(
() => props.children,
(err, reset) => {
reportError(err());
return props.fallback(err);
}
) as unknown as JSX.Element;
}
Last updated: 7/4/26, 6:21 PMEdit this pageReport an issue with this page