-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy path_error.tsx
More file actions
38 lines (31 loc) · 1004 Bytes
/
_error.tsx
File metadata and controls
38 lines (31 loc) · 1004 Bytes
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
import * as Sentry from '@sentry/nextjs';
import type { NextPageContext } from 'next';
import Error from 'next/error';
import { NotFoundCard } from '../components/Layout/NotFoundCard';
import {
createI18nStore,
I18nContext,
I18nProps,
loadSSRLanguage,
} from '../models/Translation';
const enableSentry =
process.env.NODE_ENV === 'development' || !process.env.SENTRY_AUTH_TOKEN;
export default class CustomError extends Error<I18nProps> {
static async getInitialProps(context: NextPageContext) {
if (enableSentry) await Sentry.captureUnderscoreErrorException(context);
return {
...(await Error.getInitialProps(context)),
...(await loadSSRLanguage(context)),
};
}
i18nStore = createI18nStore(this.props.language, this.props.languageMap);
render() {
const { props, i18nStore } = this;
return (
<I18nContext.Provider value={i18nStore}>
<Error {...props} />
<NotFoundCard {...props} />
</I18nContext.Provider>
);
}
}