@gluonjs/reactivity / packages/reactivity/src / ReactivityErrorContext
Interface: ReactivityErrorContext
Properties
error
readonlyerror:unknown
phase
readonlyphase:ReactivityErrorPhase
source?
readonlyoptionalsource?:unknown
Example
Receive the thrown value, lifecycle phase, and optional source associated with an unhandled reactivity failure:
import {
queueJob,
setReactivityErrorHandler,
type ReactivityErrorContext,
type ReactivityErrorHandler,
type ReactivityErrorPhase,
} from '@gluonjs/reactivity';
const errors: ReactivityErrorContext[] = [];
const handler: ReactivityErrorHandler = (context) => { errors.push(context); };
const phase: ReactivityErrorPhase = 'scheduler';
const restore = setReactivityErrorHandler(handler);
queueJob(() => { throw new Error('Inventory failed'); });
await Promise.resolve();
console.log(errors[0]?.phase === phase);
restore();