-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2582 from opossum-tool/fix-error-boundary
fix: introduce proper error boundary
- Loading branch information
Showing
14 changed files
with
119 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 0 additions & 110 deletions
110
src/Frontend/Components/ErrorBoundary/ErrorBoundary.tsx
This file was deleted.
Oops, something went wrong.
62 changes: 0 additions & 62 deletions
62
src/Frontend/Components/ErrorBoundary/__tests__/ErrorBoundary.test.tsx
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
src/Frontend/Components/ErrorFallback/ErrorFallback.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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 { styled } from '@mui/material'; | ||
|
||
export const Container = styled('div')({ | ||
display: 'flex', | ||
flexDirection: 'row', | ||
height: '100%', | ||
width: '100%', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}); | ||
|
||
export const TextContainer = styled('div')({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '20px', | ||
width: 'fit-content', | ||
maxWidth: '600px', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters