Generalize apiError