-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(error): fix generic error boundary message (#33)
- Loading branch information
Showing
13 changed files
with
105 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn lint-staged | ||
# yarn lint-staged |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import AwsLogo from './aws-logo.svg?react' | ||
import DiscrodIcon from './discord-icon.svg?react' | ||
import FixLogo from './fix-logo.svg?react' | ||
import GcpLogo from './gcp-logo.svg?react' | ||
import GithubSEBIcon from './github-seb-icon.svg?react' | ||
import GoogleSEBIcon from './google-seb-icon.svg?react' | ||
import LogoWhiteNoBackground from './logo-white-no-background.svg?react' | ||
|
||
export { AwsLogo, FixLogo, GcpLogo, GithubSEBIcon, GoogleSEBIcon, LogoWhiteNoBackground } | ||
export { AwsLogo, DiscrodIcon, FixLogo, GcpLogo, GithubSEBIcon, GoogleSEBIcon, LogoWhiteNoBackground } |
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
65 changes: 58 additions & 7 deletions
65
src/shared/error-boundary-fallback/ErrorBoundaryFallback.tsx
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 |
---|---|---|
@@ -1,13 +1,64 @@ | ||
import { Box, Button, Typography } from '@mui/material' | ||
import { Trans } from '@lingui/macro' | ||
import BuildIcon from '@mui/icons-material/Build' | ||
import { Button, Divider, Link, Modal, Stack, Typography, styled } from '@mui/material' | ||
import { useEffect } from 'react' | ||
import { FallbackProps } from 'react-error-boundary' | ||
import { DiscrodIcon } from 'src/assets/icons' | ||
import { env } from 'src/shared/constants' | ||
|
||
const ModalContent = styled(Stack)(({ theme }) => ({ | ||
position: 'absolute', | ||
top: '50%', | ||
left: '50%', | ||
transform: 'translate(-50%, -50%)', | ||
width: '600px', | ||
maxWidth: `calc(100% - ${theme.spacing(2)}px)`, | ||
backgroundColor: theme.palette.background.paper, | ||
borderRadius: 4, | ||
boxShadow: theme.shadows[24], | ||
padding: theme.spacing(2, 4, 3), | ||
})) | ||
|
||
export const ErrorBoundaryFallback = ({ error, resetErrorBoundary }: FallbackProps) => { | ||
useEffect(() => { | ||
console.error(error) | ||
}, [error]) | ||
|
||
return ( | ||
<Box display="flex" flexDirection="column" p={2}> | ||
<Typography color="error">{(error as Error).message}</Typography> | ||
<Button onClick={resetErrorBoundary} variant="contained" sx={{ mt: 1 }} color="warning"> | ||
Reset | ||
</Button> | ||
</Box> | ||
<Modal open onClose={resetErrorBoundary} aria-labelledby="modal-error-title" aria-describedby="modal-error-description"> | ||
<ModalContent spacing={2}> | ||
<Typography id="modal-error-title" variant="h5" component={Stack} alignItems="center" direction="row"> | ||
<BuildIcon color="error" sx={{ mr: 1 }} /> | ||
<Trans>Oops! Something went wrong.</Trans> | ||
</Typography> | ||
<Typography id="modal-error-description" textAlign="justify" mb={1}> | ||
<Trans> | ||
We're sorry for the inconvenience. Our team has been notified, and the issue is being looked into. Please try again in a few | ||
minutes. If the problem persists, feel free to contact us{' '} | ||
<Link href={env.discordUrl} target="_blank"> | ||
on Discord | ||
</Link> | ||
. Thanks for your patience! | ||
</Trans> | ||
</Typography> | ||
<Divider /> | ||
<Stack spacing={1} justifyContent="end" direction="row"> | ||
<Button | ||
onClick={resetErrorBoundary} | ||
variant="contained" | ||
sx={{ mt: 1 }} | ||
color="primary" | ||
startIcon={<DiscrodIcon />} | ||
href={env.discordUrl} | ||
target="_blank" | ||
> | ||
Discord | ||
</Button> | ||
<Button onClick={resetErrorBoundary} variant="outlined" sx={{ mt: 1 }} color="warning"> | ||
<Trans>Try again</Trans> | ||
</Button> | ||
</Stack> | ||
</ModalContent> | ||
</Modal> | ||
) | ||
} |
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