node package manager

connect-domain

Asynchronous error handler for Connect

About

Asynchronous error handler for Connect

Installation

npm install connect-domain

Usage

var
connect = require('connect'),
connectDomain = require('connect-domain');
 
var app = connect()
.use(connectDomain())
.use(function(reqres){
if (Math.random() > 0.5) {
throw new Error('Simple error');
}
setTimeout(function() {
if (Math.random() > 0.5) {
throw new Error('Asynchronous error from timeout');
} else {
res.end('Hello from Connect!');
}
}, 1000);
})
.use(function(errreqresnext) {
res.end(err.message);
});
 
app.listen(3000);