| 2 | import { NextPageContext } from 'next'; |
| 3 | |
| 4 | const MyError = ({ statusCode, hasGetInitialPropsRun, err }: any) => { |
| 5 | if (!hasGetInitialPropsRun && err) { |
| 6 | // getInitialProps is not called in case of |
| 7 | // https://github.com/vercel/next.js/issues/8592. As a workaround, we pass |
| 8 | // err via _app.js so it can be captured |
| 9 | console.error(err); |
| 10 | // Flushing is not required in this case as it only happens on the client |
| 11 | } |
| 12 | |
| 13 | return <NextErrorComponent statusCode={statusCode} />; |
| 14 | }; |
| 15 | |
| 16 | MyError.getInitialProps = async (context: NextPageContext) => { |
| 17 | const errorInitialProps = (await NextErrorComponent.getInitialProps( |