export type SafeTryResult = Promise< [T, undefined] | [undefined, Error | unknown] > export async function safeTry(func: Promise): SafeTryResult { try { return [await func, undefined] as const } catch (err) { return [undefined, err instanceof Error ? err : (err as unknown)] as const } }