reportGlobalError.js — react Source File
Architecture documentation for reportGlobalError.js, a javascript file in the react codebase.
Entity Profile
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
const reportGlobalError: (error: mixed) => void =
typeof reportError === 'function'
? // In modern browsers, reportError will dispatch an error event,
// emulating an uncaught JavaScript error.
reportError
: error => {
if (
typeof window === 'object' &&
typeof window.ErrorEvent === 'function'
) {
// Browser Polyfill
const message =
typeof error === 'object' &&
error !== null &&
typeof error.message === 'string'
? // eslint-disable-next-line react-internal/safe-string-coercion
String(error.message)
: // eslint-disable-next-line react-internal/safe-string-coercion
String(error);
const event = new window.ErrorEvent('error', {
bubbles: true,
cancelable: true,
message: message,
error: error,
});
const shouldLog = window.dispatchEvent(event);
if (!shouldLog) {
return;
}
} else if (
typeof process === 'object' &&
// $FlowFixMe[method-unbinding]
typeof process.emit === 'function'
) {
// Node Polyfill
process.emit('uncaughtException', error);
return;
}
console['error'](error);
};
export default reportGlobalError;
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does reportGlobalError.js do?
reportGlobalError.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in reportGlobalError.js?
reportGlobalError.js defines 1 function(s): reportGlobalError.
Where is reportGlobalError.js in the architecture?
reportGlobalError.js is located at packages/shared/reportGlobalError.js (domain: BabelCompiler, subdomain: Entrypoint, directory: packages/shared).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free