我的代码中有一个错误,它触发了警告:
DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
当这些发生时,有没有办法让Node终止?
process将为这些发出一个unhandledRejection事件,所以:
process.on('unhandledRejection', error => {
throw error;
});
Run Code Online (Sandbox Code Playgroud)