Error handling in the cycle for()

70 views Asked by At

How to make the cycle for() to restart or skip when there is an error?

My code moves on web pages, but fails on a non-existent page and returns an error and stops.

I tried try-catch, but I did not understand how to do a re-start or skip.

It should be a simple solution.

1

There are 1 answers

0
choz On
function A() {
  // do something
}

function B() {
  try {
    // A();
  }
  catch(Exception e){
    log ( e );
    A();
  }
  finally {
    // whatever you want whether theres an exception or not
  }
}

I don't know if this might work, but it worths a try.