Created
September 12, 2011 23:27
-
-
Save xk/1212757 to your computer and use it in GitHub Desktop.
app status
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
| var appStatus; | |
| process.on('uncaughtException', function globalErrHandler (error) { | |
| console.log('An error happened when the appStatus was '+ appStatus); | |
| switch (appStatus) { | |
| case 1: //recover from status 1 | |
| case 2: //idem from status 2 | |
| case 3: //etc. | |
| case 4: | |
| } | |
| process.nextTick(loop); //keep going | |
| }); | |
| function mayThrow () { if (Math.random() > 0.999999) throw Error() } | |
| function loop () { | |
| appStatus= 1, mayThrow(); | |
| appStatus= 2, mayThrow(); | |
| appStatus= 3, mayThrow(); | |
| appStatus= 4, mayThrow(); | |
| process.nextTick(loop); | |
| } | |
| loop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment