Improve HTTP error handling