Skip to content

Instantly share code, notes, and snippets.

@wizardnet972
Last active November 25, 2017 12:35
Show Gist options
  • Select an option

  • Save wizardnet972/e3f4ea041a818cd9fcab28dcfbf526e2 to your computer and use it in GitHub Desktop.

Select an option

Save wizardnet972/e3f4ea041a818cd9fcab28dcfbf526e2 to your computer and use it in GitHub Desktop.
router.all('/incaseoferror', async(req, res, next) => {
const promise = await new Promise(function (resolve, reject) {
setTimeout(function () {
reject(new Error('this is a test err'));
}, 3000);
});
// throw new Error('test error');
});
function clientErrorHandler(err, req, res, next) {
console.log('in clientErrorHandler', err);
//but not catch the promise error!
});
process.on('uncaughtException', function (error) {
// the error is catch here..
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment