A cleaner alternative would be the following:
Due to the fact that every async function is technically a promise
You can add catches to functions when calling them with await
async function a(){
let error;
// log the error on the parent
await b().catch((err)=>console.log('b.failed'))
// change an error variable
await c().catch((err)=>{error=true; console.log(err)})
// return whatever you want
return error ? d() : null;
}
a().catch(()=>console.log('main program failed'))
No need for try catch, as all promises errors are handled, and you have no code errors, you can omit that in the parent!!
Lets say you are working with mongodb, if there is an error you might prefer to handle it in the function calling it than making wrappers, or using try catches.