I have added error logging to Sentry using Sentry.captureException. The _info object which includes the componentStack will be sent in extra data along with the exception.
24 lines
643 B
TypeScript
24 lines
643 B
TypeScript
import { ErrorInfo, ReactNode } from 'react';
|
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
import * as Sentry from '@sentry/react';
|
|
|
|
import { GenericErrorFallback } from '@/error-handler/components/GenericErrorFallback';
|
|
|
|
export const AppErrorBoundary = ({ children }: { children: ReactNode }) => {
|
|
const handleError = (_error: Error, _info: ErrorInfo) => {
|
|
Sentry.captureException(_error, (scope) => {
|
|
scope.setExtras({ _info });
|
|
return scope;
|
|
});
|
|
};
|
|
|
|
return (
|
|
<ErrorBoundary
|
|
FallbackComponent={GenericErrorFallback}
|
|
onError={handleError}
|
|
>
|
|
{children}
|
|
</ErrorBoundary>
|
|
);
|
|
};
|