Skip to content

Function: rethrowLater()

API / @xmachines/core / utils / rethrowLater

function rethrowLater(error): void;

Defined in: packages/core/src/utils/rethrow-later.ts:28

Throws an error again from a microtask of its own, and returns at once.

A throw from a microtask reaches the global handler of the runtime — the error event and window.onerror in a page, uncaughtException in Node — and it touches the current stack not. It is not a rejection, so unhandledrejection does not see it.

Use it where a throw must not leave the current code: an error handler that a renderer contains, or a callback that runs from a microtask already, so that a throw from it reaches no caller.

Parameters

ParameterTypeDescription
errorunknownThe value to throw again. It is thrown as it is, so an Error keeps its identity and its stack.

Returns

void

Example

import { rethrowLater } from "@xmachines/core/utils";
<ActorProvider
actor={actor}
registryResult={registryResult}
onError={(error) => rethrowLater(error)}
>
<PlayRenderer />
</ActorProvider>;