visionmedia/superagent — pull request #226 by lbdremy (2013-05-28 13:21:52+00:00)
Title: Try/catch serialize method and handle error after parsing

Hello @visionmedia,

I just added a try/catch around the serialize method and returned the error if any after parsing the body via the method `Request.prototype.callback`.
I added a few tests and fix the test `should map "json"` in `basic.js`, have a look to the commit.
Also I added a test using the pipe style instead of the callback style [here](https://github.com/lbdremy/superagent/commit/c36e1f746a9c126c55ff514567e8a748e4dde2b5), for some reason the test fails with the output, I don't understand why the request object is not there:

```
1) req.send(Object) as "json" should catch error when serializing (pipe style):
TypeError: Cannot call method 'on' of undefined
at Request.pipe (/home/lbdremy/workspace/nodejs/superagent/lib/node/index.js:384:18)
at Context.request.get.send.tobi (/home/lbdremy/workspace/nodejs/superagent/test/node/json.js:61:6)
at Test.Runnable.run (/home/lbdremy/workspace/nodejs/superagent/node_modules/mocha/lib/runnable.js:196:15)
at Runner.runTest (/home/lbdremy/workspace/nodejs/superagent/node_modules/mocha/lib/runner.js:351:10)
at Runner.runTests.next (/home/lbdremy/workspace/nodejs/superagent/node_modules/mocha/lib/runner.js:397:12)
at next (/home/lbdremy/workspace/nodejs/superagent/node_modules/mocha/lib/runner.js:277:14)
at Runner.hooks (/home/lbdremy/workspace/nodejs/superagent/node_modules/mocha/lib/runner.js:286:7)
at next (/home/lbdremy/workspace/nodejs/superagent/node_modules/mocha/lib/runner.js:234:23)
at Runner.hook (/home/lbdremy/workspace/nodejs/superagent/node_modules/mocha/lib/runner.js:254:5)
at process.startup.processNextTick.process._tickCallback (node.js:245:9)
```