Skip to content

Instantly share code, notes, and snippets.

@kristjan
Created September 10, 2012 20:50
Show Gist options
  • Save kristjan/3693757 to your computer and use it in GitHub Desktop.
Save kristjan/3693757 to your computer and use it in GitHub Desktop.
var domain = require('domain');
process.on('uncaughtException', function(err) {
console.log('Pre caught', err.message);
});
var d = domain.create();
d.on('error', function(err) {
console.log("Domain caught", err.message);
});
d.run(function() {
process.nextTick(function() {
throw new Error("Boom");
});
});
process.on('uncaughtException', function(err) {
console.log('Post caught', err.message);
});
Domain caught Boom
Pre caught Boom
Post caught Boom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment