From f425e6ba63d0343c47bb92b446ca49eb56bd036e Mon Sep 17 00:00:00 2001 From: jeffvli Date: Sun, 30 Nov 2025 13:37:33 -0800 Subject: [PATCH] add component error boundary --- .../components/component-error-boundary.tsx | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/renderer/features/shared/components/component-error-boundary.tsx diff --git a/src/renderer/features/shared/components/component-error-boundary.tsx b/src/renderer/features/shared/components/component-error-boundary.tsx new file mode 100644 index 000000000..dda165c0f --- /dev/null +++ b/src/renderer/features/shared/components/component-error-boundary.tsx @@ -0,0 +1,54 @@ +import { ErrorBoundary } from 'react-error-boundary'; +import { useTranslation } from 'react-i18next'; + +import { Box } from '/@/shared/components/box/box'; +import { Button } from '/@/shared/components/button/button'; +import { Center } from '/@/shared/components/center/center'; +import { Group } from '/@/shared/components/group/group'; +import { Icon } from '/@/shared/components/icon/icon'; +import { Stack } from '/@/shared/components/stack/stack'; +import { TextTitle } from '/@/shared/components/text-title/text-title'; + +interface ComponentErrorFallbackProps { + error: Error; + resetErrorBoundary: () => void; +} + +const ComponentErrorFallback = ({ resetErrorBoundary }: ComponentErrorFallbackProps) => { + const { t } = useTranslation(); + + const handleRefresh = () => { + window.location.reload(); + }; + + return ( + +
+ + + + + {t('error.genericError', { postProcess: 'sentenceCase' })} + + + + + + + +
+
+ ); +}; + +interface ComponentErrorBoundaryProps { + children: React.ReactNode; +} + +export const ComponentErrorBoundary = ({ children }: ComponentErrorBoundaryProps) => { + return {children}; +};