MCPcopy Create free account
hub / github.com/reactjs/react-rails / handleError

Function handleError

lib/assets/react-source/development/react.js:25673–25716  ·  view source on GitHub ↗
(root, thrownValue)

Source from the content-addressed store, hash-verified

25671 }
25672
25673 function handleError(root, thrownValue) {
25674 do {
25675 try {
25676 // Reset module-level state that was set during the render phase.
25677 resetContextDependencies();
25678 resetHooksAfterThrow();
25679 resetCurrentFiber();
25680
25681 if (workInProgress === null || workInProgress.return === null) {
25682 // Expected to be working on a non-root fiber. This is a fatal error
25683 // because there's no ancestor that can handle it; the root is
25684 // supposed to capture all errors that weren't caught by an error
25685 // boundary.
25686 workInProgressRootExitStatus = RootFatalErrored;
25687 workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next
25688 // sibling, or the parent if there are no siblings. But since the root
25689 // has no siblings nor a parent, we set it to null. Usually this is
25690 // handled by `completeUnitOfWork` or `unwindWork`, but since we're
25691 // interntionally not calling those, we need set it here.
25692 // TODO: Consider calling `unwindWork` to pop the contexts.
25693
25694 workInProgress = null;
25695 return null;
25696 }
25697
25698 if (enableProfilerTimer && workInProgress.mode & ProfileMode) {
25699 // Record the time spent rendering before an error was thrown. This
25700 // avoids inaccurate Profiler durations in the case of a
25701 // suspended render.
25702 stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true);
25703 }
25704
25705 throwException(root, workInProgress.return, workInProgress, thrownValue, renderExpirationTime$1);
25706 workInProgress = completeUnitOfWork(workInProgress);
25707 } catch (yetAnotherThrownValue) {
25708 // Something in the return path also threw.
25709 thrownValue = yetAnotherThrownValue;
25710 continue;
25711 } // Return to the normal work loop.
25712
25713
25714 return;
25715 } while (true);
25716 }
25717
25718 function pushDispatcher(root) {
25719 var prevDispatcher = ReactCurrentDispatcher$1.current;

Callers 2

performSyncWorkOnRootFunction · 0.85

Calls 6

resetContextDependenciesFunction · 0.85
resetHooksAfterThrowFunction · 0.85
resetCurrentFiberFunction · 0.85
throwExceptionFunction · 0.85
completeUnitOfWorkFunction · 0.85

Tested by

no test coverage detected