mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
2b252acea4
This event can be used to overwrite the default exception mechanism which reports the exception and kills the node process. See google group post: http://groups.google.com/group/nodejs/browse_thread/thread/9721dc3a2638446f
26 lines
570 B
JavaScript
26 lines
570 B
JavaScript
process.mixin(require("./common"));
|
|
|
|
var MESSAGE = 'catch me if you can';
|
|
var caughtException = false;
|
|
|
|
process.addListener('uncaughtException', function (e) {
|
|
puts("uncaught exception! 1");
|
|
assertEquals(MESSAGE, e.message);
|
|
caughtException = true;
|
|
});
|
|
|
|
process.addListener('uncaughtException', function (e) {
|
|
puts("uncaught exception! 2");
|
|
assertEquals(MESSAGE, e.message);
|
|
caughtException = true;
|
|
});
|
|
|
|
setTimeout(function() {
|
|
throw new Error(MESSAGE);
|
|
}, 10);
|
|
|
|
process.addListener("exit", function () {
|
|
puts("exit");
|
|
assertTrue(caughtException);
|
|
});
|