MCPcopy Create free account
hub / github.com/reactjs/react-rails / logCapturedError

Function logCapturedError

lib/assets/react-source/development/react.js:23174–23224  ·  view source on GitHub ↗
(capturedError)

Source from the content-addressed store, hash-verified

23172 }
23173
23174 function logCapturedError(capturedError) {
23175
23176 var error = capturedError.error;
23177
23178 {
23179 var componentName = capturedError.componentName,
23180 componentStack = capturedError.componentStack,
23181 errorBoundaryName = capturedError.errorBoundaryName,
23182 errorBoundaryFound = capturedError.errorBoundaryFound,
23183 willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling
23184 // `preventDefault()` in window `error` handler.
23185 // We record this information as an expando on the error.
23186
23187 if (error != null && error._suppressLogging) {
23188 if (errorBoundaryFound && willRetry) {
23189 // The error is recoverable and was silenced.
23190 // Ignore it and don't print the stack addendum.
23191 // This is handy for testing error boundaries without noise.
23192 return;
23193 } // The error is fatal. Since the silencing might have
23194 // been accidental, we'll surface it anyway.
23195 // However, the browser would have silenced the original error
23196 // so we'll print it first, and then print the stack addendum.
23197
23198
23199 console['error'](error); // Don't transform to our wrapper
23200 // For a more detailed description of this block, see:
23201 // https://github.com/facebook/react/pull/13384
23202 }
23203
23204 var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : 'The above error occurred in one of your React components:';
23205 var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow.
23206
23207 if (errorBoundaryFound && errorBoundaryName) {
23208 if (willRetry) {
23209 errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + ".");
23210 } else {
23211 errorBoundaryMessage = "This error was initially handled by the error boundary " + errorBoundaryName + ".\n" + "Recreating the tree from scratch failed so React will unmount the tree.";
23212 }
23213 } else {
23214 errorBoundaryMessage = 'Consider adding an error boundary to your tree to customize error handling behavior.\n' + 'Visit https://fb.me/react-error-boundaries to learn more about error boundaries.';
23215 }
23216
23217 var combinedMessage = "" + componentNameMessage + componentStack + "\n\n" + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack.
23218 // We don't include the original error message and JS stack because the browser
23219 // has already printed it. Even if the application swallows the error, it is still
23220 // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils.
23221
23222 console['error'](combinedMessage); // Don't transform to our wrapper
23223 }
23224 }
23225
23226 var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
23227

Callers 1

logErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected