什么是等效的Bluebird Promise错误记录到此:
if (err) {
console.log(err);
res.send(err);
}
为了这:
}).catch(Promise.OperationalError, function(e){
// handle error in Mongoose save findOne etc, res.send(...)
}).catch(function(e){
// handle other exceptions here, this is most likely
// a 500 error where the top one is a 4XX, but pay close
// attention to how you handle errors here
});
最佳答案
蓝鸟会自动为您记录未处理的拒绝。如果您希望对错误发送服务器响应并将该链标记为已处理,则可以执行以下操作:
.catch(function(err){
console.log(err);
res.send(err);
throw err; // this is optional, if you don't want to mark the chain as handled.
});
关于node.js - Bluebird 捕获错误记录语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24713988/