_error.jsx17 lines · main
1import * as Sentry from '@sentry/nextjs'
2import Error from 'next/error'
3
4const CustomErrorComponent = (props) => {
5 return <Error statusCode={props.statusCode} />
6}
7
8CustomErrorComponent.getInitialProps = async (contextData) => {
9 // In case this is running in a serverless function, await this in order to give Sentry
10 // time to send the error before the lambda exits
11 await Sentry.captureUnderscoreErrorException(contextData)
12
13 // This will contain the status code of the response
14 return Error.getInitialProps(contextData)
15}
16
17export default CustomErrorComponent