赞
踩
function cb(){
console.log('444');
fdsaf.fdafdas = 777;
}
new Promise((resolve,reject)=>{
cb(1)
})
https://nodejs.org/dist/latest-v4.x/docs/api/process.html#process_event_unhandledrejection
process.on('unhandledRejection', (reason, p) => {
console.log("Unhandled Rejection at: Promise ", p, " reason: ", reason);
// application specific logging, throwing an error, or other logic here
});
process.on('unhandledRejection', (reason, p) => {
console.log("Unhandled Rejection at: Promise ", p, " reason: ", reason);
// application specific logging, throwing an error, or other logic here
});
function cb(){
console.log('444');
fdsaf.fdafdas = 777;
}
new Promise((resolve,reject)=>{
cb(1)
})
process.on('unhandledRejection', (reason, p) => {
console.log("Unhandled Rejection at: Promise ", p, " reason: ", reason.stack);
// application specific logging, throwing an error, or other logic here
});
var co = require('co');
function cb(){
console.log('444');
fdsaf.fdafdas = 777;
}
co(function*(){
console.log('1111');
throw 'myerror```';
}).then(function(value) {
console.log(value); // Success!
}).catch(err=>{
console.log('222');
console.log(err); // Error!
cb();
console.log('!!!!');
}).catch(err=>{
console.log('aaa :',err);
})
nodejs 6.6以后.对没有捕获的 reject 会发出一个警告.
promises: Unhandled rejections now emit a process warning after the first tick. (Benjamin Gruenbaum) #8223
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。