Node.js中process模块常用的属性和方法

2020-06-17 07:06:41易采站长站整理
unhandledRejection
: 同理这个便是用于捕获没有与之关联promise错误处理的reject


const unhandledRejections = new Map();
process.on('unhandledRejection', (reason, p) => {
unhandledRejections.set(p, reason);
});
process.on('rejectionHandled', (p) => {
unhandledRejections.delete(p);
});

warning: 当前进程产生一个警告的时候出发


process.on('warning', (warning) => {
console.warn(warning.name); // Print the warning name
console.warn(warning.message); // Print the warning message
console.warn(warning.stack); // Print the stack trace
});

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流。