peol/node-spotify — pull request #7 by raneksi (2013-03-30 17:39:02+00:00)
Title: Send an error object in the callback in case of non-200 response

While using the library I had a request fail with 502 Bad Gateway. This resulted in a `SyntaxError: Unexpected token <` being returned as `err` in the callback from trying to JSON.parse the response.

Comments on the fix? Not sure about the returned object but it seems like a decent way to return the status code and a possible error description in the body.

{ code: 502,
body: '

502 Bad Gateway

\n

\n

502 Bad Gateway

\n

nginx\n

\n\n' }