-
Notifications
You must be signed in to change notification settings - Fork 25
Description
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)