twilio/twilio-node — pull request #9 by fabriziomoscon (2013-06-11 17:20:40+00:00)
Title: error passed to the callback in RestClient.js contains too much data

Passing back the `request` body in case of errors causes massive problems if there is a logger such as bunyan listening for errors. In fact it tries to log all the body object which contains a binary buffer. resulting into 259M of crap

I have also added a try catch around the JSON.parse() method as good practice since it can throw.

I am not 100% sure why JSON.parse() is used in first place since `request` should parse the body if the right response header is sent from the twilio endpoint. Anyway I didn't want to change too much the library since there is no test.