Error handling ()的周期中的错误处理

Error handling ()的周期中的错误处理,error-handling,try-catch,Error Handling,Try Catch,当出现错误时,如何使()的循环重新启动或跳过 我的代码在网页上移动,但在不存在的网页上失败并返回错误并停止 我尝试了try catch,但不知道如何重新启动或跳过 这应该是一个简单的解决方案 function A() { // do something } function B() { try { // A(); } catch(Exception e){ log ( e ); A(); } finally { // whatever y

当出现错误时,如何使()的循环重新启动或跳过

我的代码在网页上移动,但在不存在的网页上失败并返回错误并停止

我尝试了
try catch
,但不知道如何重新启动或跳过

这应该是一个简单的解决方案

function A() {
  // do something
}

function B() {
  try {
    // A();
  }
  catch(Exception e){
    log ( e );
    A();
  }
  finally {
    // whatever you want whether theres an exception or not
  }
}
我不知道这是否可行,但值得一试