export type SafeTryResult<T> = Promise<
  [T, undefined] | [undefined, Error | unknown]
>

export async function safeTry<T>(func: Promise<T>): SafeTryResult<T> {
  try {
    return [await func, undefined]
  } catch (err) {
    return [undefined, err]
  }
}
