Improved error handling on API request exceptions