UNPKG

return-style

Version:

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

8 lines (7 loc) 133 B
export function getError<E = Error>(fn: () => unknown): E | undefined { try { fn() } catch (err) { return err as E } }