1

为什么域不处理以下错误?

var globalDomain = domain.createDomain();

globalDomain.run( function() {
    // Why below exception does not get handled by globalDomain?
    throw "some error"; 
});

globalDomain.on('error', function(msg) {
    console.log("In global error event:" + msg);
});

同样,它与以下代码完美配合,

var globalDomain = domain.createDomain();

globalDomain.run( function() {
    setTimeout(function(){
        throw "some error from timeout";
    },0);
});

globalDomain.on('error', function(msg) {
    console.log("In global error event:" + msg);
});
4

1 回答 1

3
var globalDomain = domain.createDomain();

globalDomain.on('error', function(msg) {
    console.log("In global error event:" + msg);
});

globalDomain.run( function() {
    //  exception gets handled by globalDomain !!
    throw "some error"; 
});
于 2013-02-07T11:42:59.900 回答