function handleError()

in Libraries/Renderer/implementations/ReactFabric-profiling.js [6664:6853]


function handleError(root$jscomp$0, thrownValue) {
  do {
    var erroredWork = workInProgress;
    try {
      resetContextDependencies();
      ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
      if (didScheduleRenderPhaseUpdate) {
        for (
          var hook = currentlyRenderingFiber$1.memoizedState;
          null !== hook;

        ) {
          var queue = hook.queue;
          null !== queue && (queue.pending = null);
          hook = hook.next;
        }
        didScheduleRenderPhaseUpdate = !1;
      }
      renderLanes = 0;
      workInProgressHook = currentHook = currentlyRenderingFiber$1 = null;
      didScheduleRenderPhaseUpdateDuringThisPass = !1;
      ReactCurrentOwner$2.current = null;
      if (null === erroredWork || null === erroredWork.return) {
        workInProgressRootExitStatus = 1;
        workInProgressRootFatalError = thrownValue;
        workInProgress = null;
        break;
      }
      erroredWork.mode & 2 &&
        stopProfilerTimerIfRunningAndRecordDelta(erroredWork, !0);
      a: {
        var root = root$jscomp$0,
          returnFiber = erroredWork.return,
          sourceFiber = erroredWork,
          value = thrownValue;
        thrownValue = workInProgressRootRenderLanes;
        sourceFiber.flags |= 8192;
        isDevToolsPresent && restorePendingUpdaters(root, thrownValue);
        if (
          null !== value &&
          "object" === typeof value &&
          "function" === typeof value.then
        ) {
          var wakeable = value,
            tag = sourceFiber.tag;
          if (
            0 === (sourceFiber.mode & 1) &&
            (0 === tag || 11 === tag || 15 === tag)
          ) {
            var currentSource = sourceFiber.alternate;
            currentSource
              ? ((sourceFiber.updateQueue = currentSource.updateQueue),
                (sourceFiber.memoizedState = currentSource.memoizedState),
                (sourceFiber.lanes = currentSource.lanes))
              : ((sourceFiber.updateQueue = null),
                (sourceFiber.memoizedState = null));
          }
          var hasInvisibleParentBoundary =
              0 !== (suspenseStackCursor.current & 1),
            workInProgress$32 = returnFiber;
          do {
            var JSCompiler_temp;
            if ((JSCompiler_temp = 13 === workInProgress$32.tag)) {
              var nextState = workInProgress$32.memoizedState;
              if (null !== nextState)
                JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1;
              else {
                var props = workInProgress$32.memoizedProps;
                JSCompiler_temp =
                  void 0 === props.fallback
                    ? !1
                    : !0 !== props.unstable_avoidThisFallback
                    ? !0
                    : hasInvisibleParentBoundary
                    ? !1
                    : !0;
              }
            }
            if (JSCompiler_temp) {
              var wakeables = workInProgress$32.updateQueue;
              if (null === wakeables) {
                var updateQueue = new Set();
                updateQueue.add(wakeable);
                workInProgress$32.updateQueue = updateQueue;
              } else wakeables.add(wakeable);
              if (
                0 === (workInProgress$32.mode & 1) &&
                workInProgress$32 !== returnFiber
              ) {
                workInProgress$32.flags |= 128;
                sourceFiber.flags |= 32768;
                sourceFiber.flags &= -10053;
                if (1 === sourceFiber.tag)
                  if (null === sourceFiber.alternate) sourceFiber.tag = 17;
                  else {
                    var update = createUpdate(-1, 1);
                    update.tag = 2;
                    enqueueUpdate(sourceFiber, update);
                  }
                sourceFiber.lanes |= 1;
                break a;
              }
              value = void 0;
              sourceFiber = thrownValue;
              var pingCache = root.pingCache;
              null === pingCache
                ? ((pingCache = root.pingCache = new PossiblyWeakMap()),
                  (value = new Set()),
                  pingCache.set(wakeable, value))
                : ((value = pingCache.get(wakeable)),
                  void 0 === value &&
                    ((value = new Set()), pingCache.set(wakeable, value)));
              if (!value.has(sourceFiber)) {
                value.add(sourceFiber);
                var ping = pingSuspendedRoot.bind(
                  null,
                  root,
                  wakeable,
                  sourceFiber
                );
                isDevToolsPresent && restorePendingUpdaters(root, sourceFiber);
                wakeable.then(ping, ping);
              }
              workInProgress$32.flags |= 16384;
              workInProgress$32.lanes = thrownValue;
              break a;
            }
            workInProgress$32 = workInProgress$32.return;
          } while (null !== workInProgress$32);
          value = Error(
            (getComponentNameFromFiber(sourceFiber) || "A React component") +
              " suspended while rendering, but no fallback UI was specified.\n\nAdd a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display."
          );
        }
        5 !== workInProgressRootExitStatus &&
          (workInProgressRootExitStatus = 2);
        value = createCapturedValue(value, sourceFiber);
        workInProgress$32 = returnFiber;
        do {
          switch (workInProgress$32.tag) {
            case 3:
              root = value;
              workInProgress$32.flags |= 16384;
              thrownValue &= -thrownValue;
              workInProgress$32.lanes |= thrownValue;
              var update$33 = createRootErrorUpdate(
                workInProgress$32,
                root,
                thrownValue
              );
              enqueueCapturedUpdate(workInProgress$32, update$33);
              break a;
            case 1:
              root = value;
              var ctor = workInProgress$32.type,
                instance = workInProgress$32.stateNode;
              if (
                0 === (workInProgress$32.flags & 128) &&
                ("function" === typeof ctor.getDerivedStateFromError ||
                  (null !== instance &&
                    "function" === typeof instance.componentDidCatch &&
                    (null === legacyErrorBoundariesThatAlreadyFailed ||
                      !legacyErrorBoundariesThatAlreadyFailed.has(instance))))
              ) {
                workInProgress$32.flags |= 16384;
                thrownValue &= -thrownValue;
                workInProgress$32.lanes |= thrownValue;
                var update$36 = createClassErrorUpdate(
                  workInProgress$32,
                  root,
                  thrownValue
                );
                enqueueCapturedUpdate(workInProgress$32, update$36);
                break a;
              }
          }
          workInProgress$32 = workInProgress$32.return;
        } while (null !== workInProgress$32);
      }
      completeUnitOfWork(erroredWork);
    } catch (yetAnotherThrownValue) {
      thrownValue = yetAnotherThrownValue;
      workInProgress === erroredWork &&
        null !== erroredWork &&
        (workInProgress = erroredWork = erroredWork.return);
      continue;
    }
    break;
  } while (1);
}