linode-api icon indicating copy to clipboard operation
linode-api copied to clipboard

Don't crash when Linode returns an invalid JSON

Open Matheus28 opened this issue 9 years ago • 1 comments

Sometimes, because of 5xx errors, Linode doesn't actually return a JSON, but an error string. That causes linode-api to crash. This patch fixes this by forwarding an invalid JSON error to the callback.

Please notice that I don't actually write in Coffeescript, but the code should be correct (it's equivalent to the change I made locally directly to the .js file to fix this).

Matheus28 avatar Dec 27 '15 23:12 Matheus28

Actually, what is happening isn't exactly invalid JSON. But the Linode API replies with no body, and body = undefined, so it JSON.parse stringifies it and that's where the "invalid JSON" comes from. The fix still stands, though.

Matheus28 avatar Jan 01 '16 20:01 Matheus28