Created
January 22, 2010 06:24
-
-
Save benw/283552 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env node | |
var sys = require('sys'); | |
process.exceptionCatcher = function (e) { | |
sys.puts('Catcher 1 catches "' + e.message + '"'); | |
sys.puts('Catcher 1 returns'); | |
} | |
setTimeout(function () { | |
sys.puts('Timeout 1 throws'); | |
throw new Error('thrown by Timeout 1'); | |
}, 100); | |
process.exceptionCatcher = function (e) { | |
sys.puts('Catcher 2 catches "' + e.message + '"'); | |
sys.puts('Catcher 2 throws'); | |
throw new Error('thrown by Catcher 2'); | |
} | |
setTimeout(function () { | |
sys.puts('Timeout 2 throws'); | |
throw new Error('thrown by Timeout 2'); | |
}, 200); | |
process.exceptionCatcher = undefined; | |
process.addListener('uncaughtException', function (e) { | |
sys.error('uncaughtException catches "' + e.message + '"'); | |
}); | |
sys.puts('Throwing from main'); | |
throw new Error('thrown by main'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment