import { type ApiError } from '@/lib/types'

export async function handleError<T>(cb: () => Promise<T>) {
    try {
        const data = await cb()
        return { data, error: null }
    } catch (e) {
        return { data: null, error: e as ApiError }
    }
}
