import React from 'react' import HTTPStatus from 'http-status' import Head from './head' export default class Error extends React.Component { static getInitialProps ({ res, err }) { const statusCode = res ? res.statusCode : (err ? err.statusCode : null) const pageNotFound = statusCode === 404 || (err ? err.pageNotFound : false) return { statusCode, pageNotFound } } render () { const { statusCode, pageNotFound } = this.props const title = pageNotFound ? 'This page could not be found' : HTTPStatus[statusCode] || 'An unexpected error has occurred' return