Skip to main content

Function: catchIf()

catchIf<C, E, RD, CD>(runner, catchCallback?): (action) => Promise<RD | CD>

Run given runner and catch errors using catchCallback. If catchCallback is omitted, will return null on error. If catchCallback returns a function, will run it as an action's runner. Else, will ignore error and return null only if callback for error is truthy.

Type parameters

C extends object

E extends object

RD

CD = null

Parameters

runner: ContextRunner<C, E, Awaitable<RD>>

catchCallback?: CatchCallback<C, E, CD>

Returns

Function

Parameters

action: Action<C, E>

Returns

Promise<RD | CD>

Source

packages/core/src/actions/context/runners/catchIf.ts:40