Created
July 4, 2012 11:30
-
-
Save shigeki/3046881 to your computer and use it in GitHub Desktop.
Domain Stack Sample #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// domain stack sample | |
var domain = require('domain'); | |
var d1 = domain.create(); | |
var d2 = domain.create(); | |
var d3 = domain.create(); | |
d1.on('error', function(err) { | |
console.log('d1:', err.message); | |
}); | |
d2.on('error', function(err) { | |
console.log('d2:', err.message); | |
}); | |
d3.on('error', function(err) { | |
console.log('d3:', err.message); | |
}); | |
var arg = +process.argv[2]; | |
if (arg === 1) { | |
d1.run(function() { | |
throw new Error('d1 error'); | |
}); | |
} else if (arg === 2) { | |
d2.run(function() { | |
throw new Error('d2 error'); | |
}); | |
} else if (arg === 3) { | |
d3.run(function() { | |
throw new Error('d3 error'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> node domain_stack2.js 1 | |
d1: d1 error | |
> node domain_stack2.js 2 | |
d2: d2 error | |
> node domain_stack2.js 3 | |
d3: d3 error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment