|
|
@ -105,7 +105,6 @@ d.on('error', function(er) { |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
process.on('exit', function() { |
|
|
|
console.error('exit', caught, expectCaught); |
|
|
|
assert.equal(caught, expectCaught, 'caught the expected number of errors'); |
|
|
@ -113,7 +112,6 @@ process.on('exit', function() { |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// revert to using the domain when a callback is passed to nextTick in
|
|
|
|
// the middle of a tickCallback loop
|
|
|
|
d.run(function() { |
|
|
@ -124,7 +122,6 @@ d.run(function() { |
|
|
|
expectCaught++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// catch thrown errors no matter how many times we enter the event loop
|
|
|
|
// this only uses implicit binding, except for the first function
|
|
|
|
// passed to d.run(). The rest are implicitly bound by virtue of being
|
|
|
@ -146,7 +143,6 @@ d.run(function() { |
|
|
|
expectCaught++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// implicit addition of a timer created within a domain-bound context.
|
|
|
|
d.run(function() { |
|
|
|
setTimeout(function() { |
|
|
@ -156,14 +152,12 @@ d.run(function() { |
|
|
|
expectCaught++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Event emitters added to the domain have their errors routed.
|
|
|
|
d.add(e); |
|
|
|
e.emit('error', new Error('emitted')); |
|
|
|
expectCaught++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get rid of the `if (er) return cb(er)` malarky, by intercepting
|
|
|
|
// the cb functions to the domain, and using the intercepted function
|
|
|
|
// as a callback instead.
|
|
|
@ -177,7 +171,6 @@ bound(new Error('bound')); |
|
|
|
expectCaught++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// intercepted should never pass first argument to callback
|
|
|
|
function fn2(data) { |
|
|
|
assert.equal(data, 'data', 'should not be null err argument'); |
|
|
@ -208,7 +201,6 @@ setTimeout(d.bind(thrower), 100); |
|
|
|
expectCaught++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Pass an intercepted function to an fs operation that fails.
|
|
|
|
fs.open('this file does not exist', 'r', d.intercept(function(er) { |
|
|
|
console.error('should not get here!', er); |
|
|
@ -217,7 +209,6 @@ fs.open('this file does not exist', 'r', d.intercept(function(er) { |
|
|
|
expectCaught++; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// implicit addition by being created within a domain-bound context.
|
|
|
|
var implicit; |
|
|
|
|
|
|
|