brianc/node-domain-middleware — pull request #6 by alexxiyang (2014-06-12 16:55:43+00:00)
Title: Improve README.md exmaple code to prevent TypeError

I don’t know how to thank you for your great component ! You component helps us a lot!

There is a tiny flaw in README.md
```javascript
console.log('error on request %d %s %s: %j', process.domain.id, req.method, req.url, err);
```
sometimes will occur a json parse error, see this example:

```javascript
var express = require('express');
var app = express();
var fs = require('fs');

app.use(require('express-domain-middleware'));
app.use(app.router);
app.use(function errorHandler(err, req, res, next) {
console.error('error on request %d %s %s : %j', process.domain.id, req.method, req.url,err);
console.error(err.stack);
res.send(500, "Something bad happened. :(");

});

app.get('/error', function(req, res){
console.log('process.domain.id:'+process.domain.id);
fs.open('/data/nodejs/abc.txt','r',function(er,fd){
console.log('process.domain.id:'+process.domain.id);
console.log('got abc.txt');
fs.open('/data/nodejs/no-exist-file','r',function(er,fd){
throw er;
}
);
});
});

var server = app.listen(3000, function() {
console.log('Listening on port %d', server.address().port);
});
```

it will occur an exception

```
TypeError: Converting circular structure to JSON at Object.stringify (native) at util.js:41:30 at String.replace
(native) at Console.exports.format (util.js:35:23) at Console.warn (console.js:61:34) at Object.errorHandler [as handle]
(/data/nodejs/testexpress/index.js:8:11) at next
(/data/nodejs/testexpress/node_modules/express/node_modules/connect/lib/proto.js:189:17) at Domain.
(/data/nodejs/testexpress/node_modules/express-domain-middleware/index.js:12:5) at Domain.EventEmitter.emit
(events.js:95:17) at process._fatalException (node.js:249:27)
```

So I changed it into
```javascript
console.log('error on request %d %s %s', process.domain.id, req.method, req.url);
console.log(err.stack);
```