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

Function commitErrorLogging

code/communication/public/app.js:11373–11422  ·  view source on GitHub ↗
(finishedWork, onUncaughtError)

Source from the content-addressed store, hash-verified

11371 }
11372
11373 function commitErrorLogging(finishedWork, onUncaughtError) {
11374 switch (finishedWork.tag) {
11375 case ClassComponent:
11376 {
11377 var ctor = finishedWork.type;
11378 var _instance4 = finishedWork.stateNode;
11379 var updateQueue = finishedWork.updateQueue;
11380 !(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;
11381 var capturedErrors = updateQueue.capturedValues;
11382 updateQueue.capturedValues = null;
11383
11384 if (typeof ctor.getDerivedStateFromCatch !== 'function') {
11385 // To preserve the preexisting retry behavior of error boundaries,
11386 // we keep track of which ones already failed during this batch.
11387 // This gets reset before we yield back to the browser.
11388 // TODO: Warn in strict mode if getDerivedStateFromCatch is
11389 // not defined.
11390 markLegacyErrorBoundaryAsFailed(_instance4);
11391 }
11392
11393 _instance4.props = finishedWork.memoizedProps;
11394 _instance4.state = finishedWork.memoizedState;
11395 for (var i = 0; i < capturedErrors.length; i++) {
11396 var errorInfo = capturedErrors[i];
11397 var _error = errorInfo.value;
11398 var stack = errorInfo.stack;
11399 logError(finishedWork, errorInfo);
11400 _instance4.componentDidCatch(_error, {
11401 componentStack: stack !== null ? stack : ''
11402 });
11403 }
11404 }
11405 break;
11406 case HostRoot:
11407 {
11408 var _updateQueue2 = finishedWork.updateQueue;
11409 !(_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;
11410 var _capturedErrors = _updateQueue2.capturedValues;
11411 _updateQueue2.capturedValues = null;
11412 for (var _i = 0; _i < _capturedErrors.length; _i++) {
11413 var _errorInfo = _capturedErrors[_i];
11414 logError(finishedWork, _errorInfo);
11415 onUncaughtError(_errorInfo.value);
11416 }
11417 break;
11418 }
11419 default:
11420 invariant(false, 'This unit of work tag cannot capture errors. This error is likely caused by a bug in React. Please file an issue.');
11421 }
11422 }
11423
11424 function commitAttachRef(finishedWork) {
11425 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