Skip to content

API reference / @backpack/error-handling / promises / promiseTry

Function: promiseTry()

ts
function promiseTry<T>(block): Promise<Awaited<T>>;

Executes a callback, wrapping its result in a Promise. Static version of Promise.try() (currently stage 3).

Type Parameters

Type Parameter
T

Parameters

ParameterType
block() => T | PromiseLike<T>

Returns

Promise<Awaited<T>>

See

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/try