import { ApiError } from "@/lib/types"; export async function useError(cb: () => Promise) { try { const data = await cb(); return { data, error: null } } catch (e) { return { data: null, error: e as ApiError } } }