linode-api
linode-api copied to clipboard
Don't crash when Linode returns an invalid JSON
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).
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.