user13686758
user13686758

Reputation:

Async/ await to execute multiple functions with error handling

I have a 12 async functions, all functions should get executed one after another and throw if there is any error.

async function fun1(){
...
}

async function fun2(){
...
}
async function fun3(){
...
}

async function executeAll() {
try{
  await fun1();
  await fun2();
  await fun3();
  } catch(e){
console.error(e)
}
}

It is not returning any error. Is there any way handling of individual errors with try/catch. functions ? or any other.

Upvotes: 0

Views: 159

Answers (1)

Vasyl Savchuk
Vasyl Savchuk

Reputation: 185

I think it is. You can also catch errors in promise

     executeAll.then((result)=>{
          //some code
     }).catch((err)=>{
         //handling error
     })

Upvotes: 1

Related Questions