Skip to content

Instantly share code, notes, and snippets.

@benw
Created January 22, 2010 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benw/283552 to your computer and use it in GitHub Desktop.
Save benw/283552 to your computer and use it in GitHub Desktop.
#!/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