google/google-api-nodejs-client — pull request #39 by burcu (2013-05-26 15:06:45+00:00)
Title: Error is truncated to first character

I've only tested this with `latitude.location.list`, but can reproduce every time:

1. Okay on the consent page for a client and logged in user as per [here](https://github.com/google/google-api-nodejs-client#consent-page-url).
1. Make an authenticated request for `latitude.location.list` as per [here](https://github.com/google/google-api-nodejs-client#making-authenticated-requests).
1. See that the `callback` function is called with a `null` `err` argument, and data in the second argument.
1. Go to the **Authorized Access to your Google Account page**, here:
https://accounts.google.com/b/0/IssuedAuthSubTokens

Hit *Revoke Access* for your client.
1. Make a second authenticated request for `latitude.location.list`.

* What's expected: the `callback` function's `err` argument contains a description of the error. In this case: `"invalid_auth"`.
* What's observed: the `callback` functions `err` argument is set to `"i"`.

***

The problem originates in `Request.prototype.handleResponse` [here](https://github.com/dukedave/google-api-nodejs-client/blob/0af005d034aedd051ff221c6a15a7dd21e35f870/lib/requests.js#L181), where it assumed that `errors` is an array and `errors[0]` is used.
In this case `errors` is actually a string and it strips `"invalid_grant"` down to just `"i"`.

It can be fixed by checking `util.isArray(errors)`, I'll submit a pull request in a moment.