UNPKG

return-style

Version:

Non-intrusively convert the result of any function or promise to the user's desired style.

10 lines (9 loc) 180 B
export async function getErrorPromise<E = Error>( promise: PromiseLike<unknown> ): Promise<E | undefined> { try { await promise } catch (err) { return err as E } }