Skip to content

Instantly share code, notes, and snippets.

@lu911
Last active December 17, 2015 23:29
Show Gist options
  • Save lu911/5689316 to your computer and use it in GitHub Desktop.
Save lu911/5689316 to your computer and use it in GitHub Desktop.
domainAPI - error occured from 'errorHandler'
var domain = require('domain').create(),
errorFlag = true;
domain.on('error', function()
{
console.log('error catch');
if(errorFlag == true)
errorHandler();
console.log(this)
});
function errorHandler()
{
console.log('errorHandler');
errorFlag = false;
this.helloError = domain.bind(function()
{
console.log('errorHandler - helloError');
throw new Error('error occured from domainErrorProcessor');
});
this.helloError();
}
function test()
{
this.helloError = domain.bind(function()
{
throw new Error('TEST ERROR');
});
this.helloError();
}
test();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment