/** * Wraps a promise and returns a tuple where the first element is the data if successful, * or null if an error occurred, and the second element is the error if any, or null if successful. * * @param promise The promise to wrap. * @returns A promise that resolves to [data, null] on success or [null, error] on failure. */ export async function tryCatch(promise: Promise): Promise<[T, null] | [null, E]> { try { const data = await promise; return [data, null]; } catch (error) { return [null, error as E]; } }