Loading...
Skip to main content

Module: core/error-boundary

Functions

ErrorBoundary

ErrorBoundary(props, «destructured»): AsyncGenerator<string, Node, unknown>

Handle errors. If any child throws an error, the ErrorBoundary will show its fallback value instead.

If the fallback itself throws an error, that error will be propagated. (Just like if your catch block throws an error.)

Example

 <ErrorBoundary fallback="User data could not be fetched.">
{fetchUserData()}
</ErrorBoundary>

This is useful, because without it, any exception will make your entire request fail. It also gives you a chance to instruct the model what to do in the case of failure.

This is inspired by https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary.

Parameters

NameType
propsObject
props.childrenNode
props.fallbackNode | (error: unknown) => Node
«destructured»RenderContext

Returns

AsyncGenerator<string, Node, unknown>

Defined in

ai-jsx/src/core/error-boundary.ts:19