Improved error handling by parsing any HTML responses from failed API calls