我有一个从控制人员开始、从服务到完成申请的通道、回复控制人员处理和返回前线的节点。 我对处理错误没有什么麻烦。 如果<代码>got(选项)方法失败,我就会发现500个内部错误。 如果我附上<代码>got(options)的功能,例如:
const response = await got(options).catch(err=>{
console.log( error +err.message);
console.log( error +JSON.stringify(err.body));
});
错误标识,但我不能将错误发到前端,而是将500个错误用在APIC电话上。 我尝试了多种方法,但又是新的错误处理方法,因此无法工作。
My controller code is:
router.delete( /deletePayment/:id , (req, res, next) => {
squarePaymentService.deletePayment(req.params.id)
.then(paymentResponse => res.send(paymentResponse))
.catch(err => next(err));
});
《服务守则》是:
async function deletePayment(paymentId) {
const options = await ApiOptionsService.deleteItem(paymentId)
const response = await got(options).catch(err=>{
console.log( error +err.message); //need to catch and send this error to frontend.
});
return response.body;
}
I want to catch the error in console.log( error +err.message);
and send it to the frontend.