-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathErrorFallback.tsx
52 lines (50 loc) · 1.58 KB
/
ErrorFallback.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-FileCopyrightText: Meta Platforms, Inc. and its affiliates
// SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
//
// SPDX-License-Identifier: Apache-2.0
import MuiButton from '@mui/material/Button';
import MuiButtonGroup from '@mui/material/ButtonGroup';
import MuiTypography from '@mui/material/Typography';
import { FallbackProps } from 'react-error-boundary';
import { text } from '../../../shared/text';
import { OpossumColors } from '../../shared-styles';
import { Container, TextContainer } from './ErrorFallback.style';
export const ErrorFallback: React.FC<FallbackProps> = ({
error,
resetErrorBoundary,
}) => {
return (
<Container>
<TextContainer role="alert">
<MuiTypography textAlign={'center'} variant={'h6'}>
{text.errorBoundary.unexpectedError}
</MuiTypography>
<MuiTypography
sx={{ fontFamily: 'monospace' }}
color={OpossumColors.red}
>
{error.message}
</MuiTypography>
<MuiButtonGroup fullWidth variant={'contained'}>
<MuiButton
color={'primary'}
onClick={() => {
resetErrorBoundary();
window.electronAPI.relaunch();
}}
>
{text.errorBoundary.relaunch}
</MuiButton>
<MuiButton
color={'secondary'}
onClick={() => {
window.electronAPI.quit();
}}
>
{text.errorBoundary.quit}
</MuiButton>
</MuiButtonGroup>
</TextContainer>
</Container>
);
};