API fix issue with error handling