-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement process "uncaughtException" event
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
- Loading branch information
Showing
3 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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); | ||
}); |