Skip to main content

DispatchErrorCallback

Application hook invoked when the runtime cannot recover from a dispatch failure.

Called after StateEvents.onError and StateEvents.onUnhandled have been tried and the error is still propagating, or when no recovery hook handled it. The default implementation logs via TraceWriter and rethrows the error.

Remarks

Override at construction (makeHsm(..., dispatchErrorCallback)) or assign hsm.dispatchErrorCallback for integration tests that must assert failures. Note: Hsm.sync still resolves when the default callback throws — failures surface in logs, not as a rejected sync() Promise.

Type Parameters

Context

Context

Protocol

Protocol extends { } | undefined

DispatchErrorCallback(hsm, err): void

Application hook invoked when the runtime cannot recover from a dispatch failure.

Called after StateEvents.onError and StateEvents.onUnhandled have been tried and the error is still propagating, or when no recovery hook handled it. The default implementation logs via TraceWriter and rethrows the error.

Parameters

hsm

Base<Context, Protocol>

The machine handle (Hsm or handler State view) at failure time

err

Error

The error that terminated dispatch (often EventHandlerError, UnhandledEventError, TransitionError, or FatalError)

Returns

void

Remarks

Override at construction (makeHsm(..., dispatchErrorCallback)) or assign hsm.dispatchErrorCallback for integration tests that must assert failures. Note: Hsm.sync still resolves when the default callback throws — failures surface in logs, not as a rejected sync() Promise.