【发布时间】:2018-12-20 18:40:38
【问题描述】:
我需要在 Promise 解析中捕获流事件中引发的错误。类似的东西
function foo(){
return new Promise((resolve,reject) => {
resolve(res.pipe(transfomrStream).pipe(through2.obj(function(obj, enc, callback) {
on('end', ()=>{
await httpReq(...)
.then((crudRes) => assert.strictEqual(somerthing))
})
)
})
})
}
我如何捕捉断言失败?我试图在最后一个 pipe() 或函数调用中返回错误,但我只得到 unhandled promise reject
【问题讨论】:
标签: node.js error-handling stream throw through2