The Node process will exit ungracefully if a promise throws an unhandled exception. Solution similar to below:-
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at:', p, 'reason:', reason);
// application specific logging, throwing an error, or other logic here
});
somePromise.then((res) => {
return reportToUser(JSON.pasre(res)); // note the typo (pasre)
}); // no .catch or .then
The Node process will exit ungracefully if a promise throws an unhandled exception. Solution similar to below:-
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at:', p, 'reason:', reason);
// application specific logging, throwing an error, or other logic here
});
somePromise.then((res) => {
return reportToUser(JSON.pasre(res)); // note the typo (
pasre)}); // no
.catchor.then