MCPcopy
hub / github.com/facebook/react / logUncaughtError

Function logUncaughtError

packages/react-reconciler/src/ReactFiberErrorLogger.js:130–161  ·  view source on GitHub ↗
(
  root: FiberRoot,
  errorInfo: CapturedValue<mixed>,
)

Source from the content-addressed store, hash-verified

128}
129
130export function logUncaughtError(
131 root: FiberRoot,
132 errorInfo: CapturedValue<mixed>,
133): void {
134 try {
135 if (__DEV__) {
136 componentName = errorInfo.source
137 ? getComponentNameFromFiber(errorInfo.source)
138 : null;
139 errorBoundaryName = null;
140 }
141 const error = (errorInfo.value: any);
142 if (__DEV__ && ReactSharedInternals.actQueue !== null) {
143 // For uncaught errors inside act, we track them on the act and then
144 // rethrow them into the test.
145 ReactSharedInternals.thrownErrors.push(error);
146 return;
147 }
148 const onUncaughtError = root.onUncaughtError;
149 onUncaughtError(error, {
150 componentStack: errorInfo.stack,
151 });
152 } catch (e) {
153 // This method must not throw, or React internal state will get messed up.
154 // If console.error is overridden, or logCapturedError() shows a dialog that throws,
155 // we want to report this error outside of the normal stack as a last resort.
156 // https://github.com/facebook/react/issues/13188
157 setTimeout(() => {
158 throw e;
159 });
160 }
161}
162
163export function logCaughtError(
164 root: FiberRoot,

Callers 3

handleThrowFunction · 0.90
panicOnRootErrorFunction · 0.90
createRootErrorUpdateFunction · 0.90

Calls 3

pushMethod · 0.65
onUncaughtErrorFunction · 0.50

Tested by

no test coverage detected