Add better handling of HTTP errors

In some cases our HTTP request fails, and we try to output
response.statusCode, but sometimes that isn't available.

Now we handle cases where that isn't available.