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