I need to catch errors thrown inside a stream event in promise resolution. Something like
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))
})
)
})
})
}
how could i catch assert failure? I've tried to return error inside the last pipe() or in function calling but i only get unhandled promise rejection
If you surround your code with a try catch you can at least see what your error is:
Also, if you have an
await
you cannot use.then()
. And you will have to make your functionasync
if you're doing await.