Added more robust handling of HTTP error messages.