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

Function commitErrorLogging

code/styling/public/app.js:11338–11387  ·  view source on GitHub ↗
(finishedWork, onUncaughtError)

Source from the content-addressed store, hash-verified

11336 }
11337
11338 function commitErrorLogging(finishedWork, onUncaughtError) {
11339 switch (finishedWork.tag) {
11340 case ClassComponent:
11341 {
11342 var ctor = finishedWork.type;
11343 var _instance4 = finishedWork.stateNode;
11344 var updateQueue = finishedWork.updateQueue;
11345 !(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;
11346 var capturedErrors = updateQueue.capturedValues;
11347 updateQueue.capturedValues = null;
11348
11349 if (typeof ctor.getDerivedStateFromCatch !== 'function') {
11350 // To preserve the preexisting retry behavior of error boundaries,
11351 // we keep track of which ones already failed during this batch.
11352 // This gets reset before we yield back to the browser.
11353 // TODO: Warn in strict mode if getDerivedStateFromCatch is
11354 // not defined.
11355 markLegacyErrorBoundaryAsFailed(_instance4);
11356 }
11357
11358 _instance4.props = finishedWork.memoizedProps;
11359 _instance4.state = finishedWork.memoizedState;
11360 for (var i = 0; i < capturedErrors.length; i++) {
11361 var errorInfo = capturedErrors[i];
11362 var _error = errorInfo.value;
11363 var stack = errorInfo.stack;
11364 logError(finishedWork, errorInfo);
11365 _instance4.componentDidCatch(_error, {
11366 componentStack: stack !== null ? stack : ''
11367 });
11368 }
11369 }
11370 break;
11371 case HostRoot:
11372 {
11373 var _updateQueue2 = finishedWork.updateQueue;
11374 !(_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;
11375 var _capturedErrors = _updateQueue2.capturedValues;
11376 _updateQueue2.capturedValues = null;
11377 for (var _i = 0; _i < _capturedErrors.length; _i++) {
11378 var _errorInfo = _capturedErrors[_i];
11379 logError(finishedWork, _errorInfo);
11380 onUncaughtError(_errorInfo.value);
11381 }
11382 break;
11383 }
11384 default:
11385 invariant(false, 'This unit of work tag cannot capture errors. This error is likely caused by a bug in React. Please file an issue.');
11386 }
11387 }
11388
11389 function commitAttachRef(finishedWork) {
11390 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