Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token u in JSON at position 0 #68

Open
GeoffreyPlitt opened this issue Dec 15, 2016 · 0 comments
Open

Unexpected token u in JSON at position 0 #68

GeoffreyPlitt opened this issue Dec 15, 2016 · 0 comments

Comments

@GeoffreyPlitt
Copy link

Sometimes the API returns non-JSON for error situations. When this happens, we really need to be able to see what the error was, but instead, this library is trying to parse non-JSON, and then we see a useless parse error, and then real error from the API is hidden, which makes this a very difficult situation to solve.

Solving this should be as simple as console.log()'ing the offending JSON first, before throwing the parse error. Perhaps the JSON.parse() step just needs a try/catch.

EXAMPLE:
Error: SyntaxError: Unexpected token u in JSON at position 0
at /Users/me/proj/node_modules/iron_mq/lib/client.js:61:18
at APIClient.Client.parseResponse (/Users/me/proj/node_modules/iron_core/lib/client.js:239:16)
at /Users/me/proj/node_modules/iron_mq/lib/api_client.js:72:18
at Request._callback (/Users/me/proj/node_modules/iron_core/lib/client.js:165:18)
at self.callback (/Users/me/proj/node_modules/iron_core/node_modules/request/request.js:344:22)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Request.onRequestError (/Users/me/proj/node_modules/iron_core/node_modules/request/request.js:961:8)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at TLSSocket.socketErrorListener (_http_client.js:308:9)
at emitOne (events.js:96:13)
at TLSSocket.emit (events.js:188:7)
at connectErrorNT (net.js:1016:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant