Fix API client-side error handling