mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
Add error boundary
This commit is contained in:
@@ -0,0 +1,27 @@
|
|||||||
|
import { Box, Center, Group, Stack } from '@mantine/core';
|
||||||
|
import { RiErrorWarningLine } from 'react-icons/ri';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { Button, Text } from '@/renderer/components';
|
||||||
|
|
||||||
|
const Container = styled(Box)`
|
||||||
|
background: var(--main-bg);
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const ErrorFallback = ({ error, resetErrorBoundary }: any) => {
|
||||||
|
return (
|
||||||
|
<Container>
|
||||||
|
<Center sx={{ height: '100vh' }}>
|
||||||
|
<Stack>
|
||||||
|
<Group spacing="xs">
|
||||||
|
<RiErrorWarningLine color="var(--danger-color)" size={30} />
|
||||||
|
<Text size="lg">Something went wrong</Text>
|
||||||
|
</Group>
|
||||||
|
<Text>{error.message}</Text>
|
||||||
|
<Button variant="filled" onClick={resetErrorBoundary}>
|
||||||
|
Reload
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
</Center>
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
export * from './routes/action-required-route';
|
export * from './routes/action-required-route';
|
||||||
export * from './routes/invalid-route';
|
export * from './routes/invalid-route';
|
||||||
|
export * from './components/error-fallback';
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { QueryClientProvider } from '@tanstack/react-query';
|
import { QueryClientProvider } from '@tanstack/react-query';
|
||||||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
|
||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
|
import { ErrorBoundary } from 'react-error-boundary';
|
||||||
import { I18nextProvider } from 'react-i18next';
|
import { I18nextProvider } from 'react-i18next';
|
||||||
|
import { ErrorFallback } from '@/renderer/features/action-required';
|
||||||
import { queryClient } from '@/renderer/lib/react-query';
|
import { queryClient } from '@/renderer/lib/react-query';
|
||||||
import i18n from '../i18n/i18n';
|
import i18n from '../i18n/i18n';
|
||||||
import { App } from './app';
|
import { App } from './app';
|
||||||
@@ -12,7 +14,9 @@ const root = createRoot(container);
|
|||||||
root.render(
|
root.render(
|
||||||
<I18nextProvider i18n={i18n}>
|
<I18nextProvider i18n={i18n}>
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<App />
|
<ErrorBoundary FallbackComponent={ErrorFallback}>
|
||||||
|
<App />
|
||||||
|
</ErrorBoundary>
|
||||||
<ReactQueryDevtools position="bottom-left" />
|
<ReactQueryDevtools position="bottom-left" />
|
||||||
</QueryClientProvider>
|
</QueryClientProvider>
|
||||||
</I18nextProvider>
|
</I18nextProvider>
|
||||||
|
|||||||
Reference in New Issue
Block a user