Looks like in node.js, process.domain
is null at the top level. What this means to me is that there is no "top-level domain" that errors can be thrown into. This leads me to my question:
var d = require('domain').create();
d.on('error', function(er) {
console.log(er)
})
d.run(function() {
setTimeout(function(){
throw new Error("?") // how do you throw this such that it doesn't hit the on 'error' handler but instead is treated like the error below would be?
}, 0)
})
//throw new Error("the kind of error handling i want")
Basically, I'm trying to store process.domain at one point, and then throw the exception in the context of that domain when the domain-context has changed. The problem is, since there is no "top-level domain", its unclear to me how to emulate how an exception would be handled at the top level normally.
Ideas?