v3: review some more files, add logging for unhandled promises

This commit is contained in:
Matteo Pagliazzi
2016-04-12 20:14:36 +02:00
parent 6458796a36
commit 793ce38f6b
18 changed files with 33 additions and 48 deletions

View File

@@ -20,4 +20,15 @@ if (IS_PROD) {
});
}
// Logs unhandled promises errors
// when no catch is attached to a promise a unhandledRejection event will be triggered
process.on('unhandledRejection', function handlePromiseRejection (reason, promise) {
let stack = reason.stack || reason.message || reason;
logger.error(stack, {
promise,
fullError: reason,
});
});
module.exports = logger;