MCPcopy Index your code
hub / github.com/microsoft/SandDance / createClassErrorUpdate

Function createClassErrorUpdate

docs/external/js/react-dom.development.js:20849–20906  ·  view source on GitHub ↗
(fiber, errorInfo, expirationTime)

Source from the content-addressed store, hash-verified

20847 }
20848
20849 function createClassErrorUpdate(fiber, errorInfo, expirationTime) {
20850 var update = createUpdate(expirationTime, null);
20851 update.tag = CaptureUpdate;
20852 var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
20853
20854 if (typeof getDerivedStateFromError === 'function') {
20855 var error$1 = errorInfo.value;
20856
20857 update.payload = function () {
20858 logError(fiber, errorInfo);
20859 return getDerivedStateFromError(error$1);
20860 };
20861 }
20862
20863 var inst = fiber.stateNode;
20864
20865 if (inst !== null && typeof inst.componentDidCatch === 'function') {
20866 update.callback = function callback() {
20867 {
20868 markFailedErrorBoundaryForHotReloading(fiber);
20869 }
20870
20871 if (typeof getDerivedStateFromError !== 'function') {
20872 // To preserve the preexisting retry behavior of error boundaries,
20873 // we keep track of which ones already failed during this batch.
20874 // This gets reset before we yield back to the browser.
20875 // TODO: Warn in strict mode if getDerivedStateFromError is
20876 // not defined.
20877 markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined
20878
20879 logError(fiber, errorInfo);
20880 }
20881
20882 var error$1 = errorInfo.value;
20883 var stack = errorInfo.stack;
20884 this.componentDidCatch(error$1, {
20885 componentStack: stack !== null ? stack : ''
20886 });
20887
20888 {
20889 if (typeof getDerivedStateFromError !== 'function') {
20890 // If componentDidCatch is the only error boundary method defined,
20891 // then it needs to call setState to recover from errors.
20892 // If no state update is scheduled then the boundary will swallow the error.
20893 if (fiber.expirationTime !== Sync) {
20894 error('%s: Error boundaries should implement getDerivedStateFromError(). ' + 'In that method, return a state update to display an error message or fallback UI.', getComponentName(fiber.type) || 'Unknown');
20895 }
20896 }
20897 }
20898 };
20899 } else {
20900 update.callback = function () {
20901 markFailedErrorBoundaryForHotReloading(fiber);
20902 };
20903 }
20904
20905 return update;
20906 }

Callers 2

throwExceptionFunction · 0.85
captureCommitPhaseErrorFunction · 0.85

Calls 6

createUpdateFunction · 0.85
logErrorFunction · 0.85
errorFunction · 0.70
getComponentNameFunction · 0.70

Tested by

no test coverage detected