Skip to content

Instantly share code, notes, and snippets.

@lazywithclass
Last active December 11, 2015 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazywithclass/4527064 to your computer and use it in GitHub Desktop.
Save lazywithclass/4527064 to your computer and use it in GitHub Desktop.
Handling errors in nodejs with domains
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