xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

js try...finally All In One

js try...finally All In One

try...catch...finally

try {
  console.log('tryCode - Code block to run');
} catch(err) {
  console.log('catchCode - Code block to handle errors', err);
  // throw new Error(err);
} finally {
  console.log('finallyCode - Code block to be executed regardless of the try result');
}

  1. try...catch
  2. try...finally
  3. try...catch...finally

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch

demo

    try {
      this.parent = activeEffect
      activeEffect = this
      shouldTrack = true

      trackOpBit = 1 << ++effectTrackDepth

      if (effectTrackDepth <= maxMarkerBits) {
        initDepMarkers(this)
      } else {
        cleanupEffect(this)
      }
      return this.fn()
    } finally {
      if (effectTrackDepth <= maxMarkerBits) {
        finalizeDepMarkers(this)
      }

      trackOpBit = 1 << --effectTrackDepth

      activeEffect = this.parent
      shouldTrack = lastShouldTrack
      this.parent = undefined
    }

https://github.com/vuejs/core/blob/main/packages/reactivity/src/effect.ts

https://github.com/vuejs/core/blob/main/packages/reactivity/src/effect.ts#L107

https://github.com/vuejs/core/blob/main/packages/reactivity/src/effect.ts#L94-L114

refs

https://www.w3schools.com/jsref/jsref_try_catch.asp
https://www.runoob.com/jsref/jsref-try-catch.html



©xgqfrms 2012-2020

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2022-03-07 22:41  xgqfrms  阅读(34)  评论(1编辑  收藏  举报