No description, website, or topics provided.
JavaScript
Pull request Compare This branch is 4 commits behind baryshev:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.npmignore
.travis.yml
LICENSE
Makefile
README.md
index.js
package.json

README.md

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(req, res){
        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(err, req, res, next) {
        res.end(err.message);
    });

app.listen(3000);