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(function(errreqres) {
        res.end(err.message);
    }))
    .use(function(reqres){
        setTimeout(function() {
            if (Math.random() > 0.5) {
                throw new Error('Error from timeout');
            } else {
                res.end('Hello from Connect!');
            }
        }, 1000);
    });
 
app.listen(3000);