Last active
December 11, 2015 01:58
-
-
Save lazywithclass/4527064 to your computer and use it in GitHub Desktop.
Handling errors in nodejs with domains
This file contains 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
var processDomain = require('domain').create(); | |
processDomain.on('error', function(err) { | |
console.log('error received'); | |
console.log(err.domain.members); | |
return processDomain.dispose(); | |
}); | |
var runner = function(parameter) { | |
processDomain.add(parameter); | |
return processDomain.run(function() { | |
throw new Error(); | |
}); | |
}; | |
runner({id: 1}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment