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

Function commitErrorLogging

code/dependency-injection/public/app.js:11431–11480  ·  view source on GitHub ↗
(finishedWork, onUncaughtError)

Source from the content-addressed store, hash-verified

11429 }
11430
11431 function commitErrorLogging(finishedWork, onUncaughtError) {
11432 switch (finishedWork.tag) {
11433 case ClassComponent:
11434 {
11435 var ctor = finishedWork.type;
11436 var _instance4 = finishedWork.stateNode;
11437 var updateQueue = finishedWork.updateQueue;
11438 !(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;
11439 var capturedErrors = updateQueue.capturedValues;
11440 updateQueue.capturedValues = null;
11441
11442 if (typeof ctor.getDerivedStateFromCatch !== 'function') {
11443 // To preserve the preexisting retry behavior of error boundaries,
11444 // we keep track of which ones already failed during this batch.
11445 // This gets reset before we yield back to the browser.
11446 // TODO: Warn in strict mode if getDerivedStateFromCatch is
11447 // not defined.
11448 markLegacyErrorBoundaryAsFailed(_instance4);
11449 }
11450
11451 _instance4.props = finishedWork.memoizedProps;
11452 _instance4.state = finishedWork.memoizedState;
11453 for (var i = 0; i < capturedErrors.length; i++) {
11454 var errorInfo = capturedErrors[i];
11455 var _error = errorInfo.value;
11456 var stack = errorInfo.stack;
11457 logError(finishedWork, errorInfo);
11458 _instance4.componentDidCatch(_error, {
11459 componentStack: stack !== null ? stack : ''
11460 });
11461 }
11462 }
11463 break;
11464 case HostRoot:
11465 {
11466 var _updateQueue2 = finishedWork.updateQueue;
11467 !(_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;
11468 var _capturedErrors = _updateQueue2.capturedValues;
11469 _updateQueue2.capturedValues = null;
11470 for (var _i = 0; _i < _capturedErrors.length; _i++) {
11471 var _errorInfo = _capturedErrors[_i];
11472 logError(finishedWork, _errorInfo);
11473 onUncaughtError(_errorInfo.value);
11474 }
11475 break;
11476 }
11477 default:
11478 invariant(false, 'This unit of work tag cannot capture errors. This error is likely caused by a bug in React. Please file an issue.');
11479 }
11480 }
11481
11482 function commitAttachRef(finishedWork) {
11483 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