When the error parameter is not undefined, bail. Continuing further will just cause problems.
Output a more informative error log. Include the status code with the path.
Allow more status codes to succeed.
The incoming body string on an HTTP error code is probably not valid JavaScript.
Clarify error.