Files
twenty/packages/twenty-front/src/modules/error-handler/components/AppErrorBoundary.tsx
Shubham Kumar a064708d8b chore: add sentry captureException for global error logging (#5198)
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.
2024-04-29 15:53:57 +02:00

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>
);
};