2010-12-05 07:20:34 +08:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2009-11-15 06:07:54 +08:00
|
|
|
|
|
|
|
var MESSAGE = 'catch me if you can';
|
|
|
|
var caughtException = false;
|
|
|
|
|
2010-12-06 03:15:30 +08:00
|
|
|
process.addListener('uncaughtException', function(e) {
|
|
|
|
console.log('uncaught exception! 1');
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(MESSAGE, e.message);
|
2009-11-15 06:07:54 +08:00
|
|
|
caughtException = true;
|
|
|
|
});
|
|
|
|
|
2010-12-06 03:15:30 +08:00
|
|
|
process.addListener('uncaughtException', function(e) {
|
|
|
|
console.log('uncaught exception! 2');
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(MESSAGE, e.message);
|
2009-11-15 06:07:54 +08:00
|
|
|
caughtException = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
throw new Error(MESSAGE);
|
|
|
|
}, 10);
|
|
|
|
|
2010-12-06 03:15:30 +08:00
|
|
|
process.addListener('exit', function() {
|
|
|
|
console.log('exit');
|
2009-11-29 01:26:59 +08:00
|
|
|
assert.equal(true, caughtException);
|
2009-11-15 06:07:54 +08:00
|
|
|
});
|