Last active
December 17, 2015 23:29
-
-
Save lu911/5689316 to your computer and use it in GitHub Desktop.
domainAPI - error occured from 'errorHandler'
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
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