-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnhandledPromiseRejectionWarning #59
Comments
+1,我也在外层catch不到。 |
promisfy的方法需要在调用前只用 await 修饰才能被 try/catch 到,也可以使用传递 callback 函数的方式来处理错误。 |
payment.refund({
out_trade_no: "kfc001",
out_refund_no: 'kfc001_refund',
total_fee: 10 * 100,
refund_fee: 10 * 100
}, function(err, result){
/**
* 微信收到正确的请求后会给用户退款提醒
* 这里一般不用处理,有需要的话有err的时候记录一下以便排查
*/
}); nodejs 8,9,10,应该是6.6以上的都会吧。 我项目里是用 co + yield 来做异步流程控制的。 co(function*(){
let result = yield payment.refund({
out_trade_no: "kfc001",
out_refund_no: 'kfc001_refund',
total_fee: 10 * 100,
refund_fee: 10 * 100
})
}).catch(function(err){
/*注意这里的err,只有err.name, data已经丢了。
参考 Payment.prototype.validate里
error = new Error();
error.name = 'InvalidSignature';
callback(error, data);
*/
}) |
我觉得 Payment.js里最后一段 Promisify 似乎不好 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
只要出现支付失败,就会提示这个warning。
应该怎样加catch?
The text was updated successfully, but these errors were encountered: