Skip to content

Commit 533f8ad

Browse files
greg19marcelpanse
andauthored
Add error message to boundary (#822)
* Add error message to boundary * Remove console warning in ErrorAlert component Removed console warning for error messages. --------- Co-authored-by: Marcel Panse <marcel.panse@gmail.com>
1 parent 9d603a1 commit 533f8ad

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

frontend/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function App() {
6767
<>
6868
<Analytics />
6969
<Header />
70-
<ErrorBoundary fallback={<ErrorAlert />}>
70+
<ErrorBoundary FallbackComponent={ErrorAlert}>
7171
<Suspense fallback={<Spinner size="lg" overlay />}>
7272
<Outlet />
7373
</Suspense>
@@ -99,7 +99,7 @@ function App() {
9999
}
100100

101101
return (
102-
<ErrorBoundary fallback={<ErrorAlert />}>
102+
<ErrorBoundary FallbackComponent={ErrorAlert}>
103103
<DialogContext.Provider value={dialogContextValue}>
104104
<Toaster />
105105
<RouterProvider router={router} />

frontend/src/components/ErrorAlert.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { useTranslation } from 'react-i18next'
22
import { Alert, AlertDescription, AlertTitle } from './ui/alert'
33

4-
export default function ErrorAlert() {
4+
interface Props {
5+
error?: Error
6+
}
7+
8+
export default function ErrorAlert({ error }: Props) {
59
const { t } = useTranslation('common')
610
return (
7-
<Alert className="mx-auto mt-12 max-w-lg">
11+
<Alert className="mt-12 mx-auto max-w-xl">
812
<AlertTitle className="text-lg">{t('error')}</AlertTitle>
913
<AlertDescription>
1014
<p>Refresh the page to try again.</p>
@@ -15,6 +19,12 @@ export default function ErrorAlert() {
1519
</a>
1620
.
1721
</p>
22+
{error !== undefined && (
23+
<p>
24+
Please include the following error message:
25+
<span className="block font-mono border-1 border-neutral-700 p-1 rounded mt-1">{error.message}</span>
26+
</p>
27+
)}
1828
</AlertDescription>
1929
</Alert>
2030
)

0 commit comments

Comments
 (0)