_error.js 713 B

12345678910111213141516171819202122232425
  1. import React from 'react';
  2. import ContentWrapper from '@/components/Layout/ContentWrapper';
  3. // https://nextjs.org/docs/#custom-error-handling
  4. class Error extends React.Component {
  5. static getInitialProps({ res, err }) {
  6. const statusCode = res ? res.statusCode : err ? err.statusCode : null;
  7. return {
  8. namespacesRequired: ['translations'],
  9. statusCode
  10. };
  11. }
  12. render() {
  13. return (
  14. <ContentWrapper>
  15. {this.props.statusCode
  16. ? `An error ${this.props.statusCode} occurred on server`
  17. : 'An error occurred on client'}
  18. </ContentWrapper>
  19. );
  20. }
  21. }
  22. export default Error;