Created
December 18, 2014 23:52
-
-
Save jeffkole/070d621839a042bb3db4 to your computer and use it in GitHub Desktop.
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
router.get('/', function (request, response, next) { | |
if (request.query.next) { | |
// Properly handled by Express | |
next(new Error('Error that I nexted')); | |
} | |
else if (request.query['throw']) { | |
// Properly handled by Express | |
throw new Error('Error that I threw'); | |
} | |
else if (request.query.asyncNext) { | |
// Properly handled by Express | |
process.nextTick(function () { | |
next(new Error('Error that I nexted asynchronously')); | |
}); | |
} | |
else if (request.query.asyncThrow) { | |
// Not even seen by Express | |
process.nextTick(function () { | |
throw new Error('Error that I threw asynchronously'); | |
}); | |
} | |
else { | |
response.status(500).send('FAIL'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment