MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / reactErrorHandler

Function reactErrorHandler

packages/react/src/error.ts:88–103  ·  view source on GitHub ↗
(
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  callback?: (error: any, errorInfo: ErrorInfo, eventId: string) => void,
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
)

Source from the content-addressed store, hash-verified

86 * ```
87 */
88export function reactErrorHandler(
89 // eslint-disable-next-line @typescript-eslint/no-explicit-any
90 callback?: (error: any, errorInfo: ErrorInfo, eventId: string) => void,
91 // eslint-disable-next-line @typescript-eslint/no-explicit-any
92): (error: any, errorInfo: ErrorInfo) => void {
93 // eslint-disable-next-line @typescript-eslint/no-explicit-any
94 return (error: any, errorInfo: ErrorInfo) => {
95 const hasCallback = !!callback;
96 const eventId = captureReactException(error, errorInfo, {
97 mechanism: { handled: hasCallback, type: 'auto.function.react.error_handler' },
98 });
99 if (hasCallback) {
100 callback(error, errorInfo, eventId);
101 }
102 };
103}

Callers 1

error.test.tsFile · 0.90

Calls 2

captureReactExceptionFunction · 0.85
callbackFunction · 0.50

Tested by

no test coverage detected