_error.tsx 623 B

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