( root: FiberRoot, errorInfo: CapturedValue<mixed>, )
| 128 | } |
| 129 | |
| 130 | export 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 | |
| 163 | export function logCaughtError( |
| 164 | root: FiberRoot, |
no test coverage detected