My function caller
calls a function parent
which itself calls child
. If child
errors then I need to be returned to caller
.
When I reject
the promise this works, however when I try and return the promise resolve
it's not returned to caller
function caller() {
return parent()
}
async function parent(){
const child = await foo(
// more code
).catch(error=>{
if(error === 123) {
return Promise.resolve("This was resolved");
}
return Promise.reject("This was rejected");
})
}
I think a try / catch block would work but I prefer the syntax above.