This commit is contained in:
32
app/[locale]/error.tsx
Normal file
32
app/[locale]/error.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
'use client';
|
||||
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
import { useEffect } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { Container, Button } from '@/components/ui';
|
||||
|
||||
export default function Error({
|
||||
error,
|
||||
reset,
|
||||
}: {
|
||||
error: Error & { digest?: string };
|
||||
reset: () => void;
|
||||
}) {
|
||||
const t = useTranslations('Error');
|
||||
|
||||
useEffect(() => {
|
||||
Sentry.captureException(error);
|
||||
}, [error]);
|
||||
|
||||
return (
|
||||
<Container className="py-24 flex flex-col items-center justify-center text-center min-h-[60vh]">
|
||||
<h2 className="text-3xl font-bold mb-4">{t('title')}</h2>
|
||||
<p className="text-white/60 mb-8 max-w-md">
|
||||
{t('description')}
|
||||
</p>
|
||||
<Button onClick={() => reset()}>
|
||||
{t('tryAgain')}
|
||||
</Button>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
24
app/global-error.tsx
Normal file
24
app/global-error.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
'use client';
|
||||
|
||||
import * as Sentry from '@sentry/nextjs';
|
||||
import Error from 'next/error';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export default function GlobalError({
|
||||
error,
|
||||
}: {
|
||||
error: Error & { digest?: string };
|
||||
}) {
|
||||
useEffect(() => {
|
||||
Sentry.captureException(error);
|
||||
}, [error]);
|
||||
|
||||
return (
|
||||
<html>
|
||||
<body>
|
||||
{/* This is the default Next.js error component but it doesn't allow omitting the statusCode */}
|
||||
<Error statusCode={0} />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user