jeudi 19 septembre 2019

Javascript code design: how to try catch each line in a good way?

My goal is to catch the error of each line and even there is an error, still run the remaining code, like this:

try {
  doFirstThing()
} catch(err) {
  //not important
}
try {
  doSecondThing()
} catch(err) {
  //not important
}
try {
  doSecondThing()
} catch(err) {
  //not important
}
//...
try {
  doLastThing()
} catch(err) {
  //not important
}

My question is: Do I have to try-catch each line to do this? Or there is a clever equivalent way that can have this done in a more elegant manner?

Aucun commentaire:

Enregistrer un commentaire