Last active
December 10, 2015 23:08
-
-
Save bengl/4507125 to your computer and use it in GitHub Desktop.
domains don't really catch exceptions?
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
// node >= 0.8.* | |
var domain = require('domain'); | |
process.on('uncaughtException', function(error){ | |
console.error('UNCAUGHT!', error); | |
}); | |
var d = domain.create(); | |
d.on('error', function(error) { | |
console.error('CAUGHT!', error); | |
}); | |
d.run(function(){ | |
process.nextTick(function(){ | |
throw Error('This is an error.'); | |
}) | |
}); | |
/* OUTPUT: | |
CAUGHT! { [Error: This is an error.] | |
domain_thrown: true, | |
domain: | |
{ domain: null, | |
_events: { error: [Function] }, | |
_maxListeners: 10, | |
members: [] } } | |
UNCAUGHT! { [Error: This is an error.] | |
domain_thrown: true, | |
domain: | |
{ domain: null, | |
_events: { error: [Function] }, | |
_maxListeners: 10, | |
members: [] } } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment