_error.jsx17 lines · main
| 1 | import * as Sentry from '@sentry/nextjs' |
| 2 | import Error from 'next/error' |
| 3 | |
| 4 | const CustomErrorComponent = (props) => { |
| 5 | return <Error statusCode={props.statusCode} /> |
| 6 | } |
| 7 | |
| 8 | CustomErrorComponent.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 | |
| 17 | export default CustomErrorComponent |