const awaitToError = async ( p: Promise ): Promise<[E | null, T | null]> => { try { const r = await Promise.resolve(p); return [null, r]; } catch (e) { return [e as E | null, null]; } }; export default awaitToError;