Improved HTTP error handling.