【问题标题】:Error handling in the cycle for()for() 循环中的错误处理
【发布时间】:2015-06-09 21:25:25
【问题描述】:

如何让循环for()出现错误时重启或跳过?

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

我试过try-catch,但我不明白如何重新开始或跳过。

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

【问题讨论】:

    标签: error-handling try-catch


    【解决方案1】:
    function A() {
      // do something
    }
    
    function B() {
      try {
        // A();
      }
      catch(Exception e){
        log ( e );
        A();
      }
      finally {
        // whatever you want whether theres an exception or not
      }
    }
    

    我不知道这是否可行,但值得一试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-12
      • 1970-01-01
      • 2017-12-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多