beatfactor/nightwatch — pull request #265 by geekdave (2014-09-11 22:54:36+00:00)
Title: Show meaningful HTTP error response

When communicating with a remote Selenium server, such as SauceLabs, sometimes there is an error establishing a connection.

The error shown on the console isn't very helpful in figuring out what the problem is.

Here's the console output when there's an authentication error:

```
SyntaxError: Unexpected token S
at Object.parse (native)
at parseResult (/Users/dcadwal/dev/magellan/node_modules/nightwatch/lib/http/request.js:230:21)
at IncomingMessage.
```

With this PR, if the HTTP response fails to parse as JSON, we just dump the raw message to the console like so:

```
Sauce Labs Authentication Error.
You used username 'foo' and access key 'XXXXXXXX-XXXX-XXXX-XXXX-XXXX' to authenticate, which are not valid Sauce Labs credentials.
```

That makes it much easier to figure out what's wrong.