MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / commitErrorLogging

Function commitErrorLogging

code/controlled-uncontrolled/public/app.js:10662–10711  ·  view source on GitHub ↗
(finishedWork, onUncaughtError)

Source from the content-addressed store, hash-verified

10660 }
10661
10662 function commitErrorLogging(finishedWork, onUncaughtError) {
10663 switch (finishedWork.tag) {
10664 case ClassComponent:
10665 {
10666 var ctor = finishedWork.type;
10667 var _instance4 = finishedWork.stateNode;
10668 var updateQueue = finishedWork.updateQueue;
10669 !(updateQueue !== null && updateQueue.capturedValues !== null) ? invariant(false, 'An error logging effect should not have been scheduled if no errors were captured. This error is likely caused by a bug in React. Please file an issue.') : void 0;
10670 var capturedErrors = updateQueue.capturedValues;
10671 updateQueue.capturedValues = null;
10672
10673 if (typeof ctor.getDerivedStateFromCatch !== 'function') {
10674 // To preserve the preexisting retry behavior of error boundaries,
10675 // we keep track of which ones already failed during this batch.
10676 // This gets reset before we yield back to the browser.
10677 // TODO: Warn in strict mode if getDerivedStateFromCatch is
10678 // not defined.
10679 markLegacyErrorBoundaryAsFailed(_instance4);
10680 }
10681
10682 _instance4.props = finishedWork.memoizedProps;
10683 _instance4.state = finishedWork.memoizedState;
10684 for (var i = 0; i < capturedErrors.length; i++) {
10685 var errorInfo = capturedErrors[i];
10686 var _error = errorInfo.value;
10687 var stack = errorInfo.stack;
10688 logError(finishedWork, errorInfo);
10689 _instance4.componentDidCatch(_error, {
10690 componentStack: stack !== null ? stack : ''
10691 });
10692 }
10693 }
10694 break;
10695 case HostRoot:
10696 {
10697 var _updateQueue2 = finishedWork.updateQueue;
10698 !(_updateQueue2 !== null && _updateQueue2.capturedValues !== null) ? invariant(false, 'An error logging effect should not have been scheduled if no errors were captured. This error is likely caused by a bug in React. Please file an issue.') : void 0;
10699 var _capturedErrors = _updateQueue2.capturedValues;
10700 _updateQueue2.capturedValues = null;
10701 for (var _i = 0; _i < _capturedErrors.length; _i++) {
10702 var _errorInfo = _capturedErrors[_i];
10703 logError(finishedWork, _errorInfo);
10704 onUncaughtError(_errorInfo.value);
10705 }
10706 break;
10707 }
10708 default:
10709 invariant(false, 'This unit of work tag cannot capture errors. This error is likely caused by a bug in React. Please file an issue.');
10710 }
10711 }
10712
10713 function commitAttachRef(finishedWork) {
10714 var ref = finishedWork.ref;

Callers 1

commitAllLifeCyclesFunction · 0.70

Calls 4

invariantFunction · 0.70
logErrorFunction · 0.70
onUncaughtErrorFunction · 0.70

Tested by

no test coverage detected