type Result = [null, T] | [E, null]; /** * Try catch wrapper for async functions */ export async function tryCatch(promise: Promise): Promise> { try { return [null, await promise]; } catch (e) { return [e instanceof Error ? e : new Error(`Error in tryCatch: ${e}`), null] as Result; } }