import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { getEnvironmentType } from '../../../../app/scripts/lib/util'; import { ENVIRONMENT_TYPE_POPUP } from '../../../../shared/constants/app'; class ErrorPage extends PureComponent { static contextTypes = { t: PropTypes.func.isRequired, }; static propTypes = { error: PropTypes.object.isRequired, }; renderErrorDetail(content) { return (
  • {content}

  • ); } renderErrorStack(title, stack) { return (
  • {title}
    {stack}
  • ); } render() { const { error } = this.props; const { t } = this.context; const isPopup = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP; const supportLink = ( {this.context.t('here')} ); const message = isPopup ? t('errorPagePopupMessage', [supportLink]) : t('errorPageMessage', [supportLink]); return (

    {t('errorPageTitle')}

    {message}

    {t('errorDetails')}
      {error.message ? this.renderErrorDetail(t('errorMessage', [error.message])) : null} {error.code ? this.renderErrorDetail(t('errorCode', [error.code])) : null} {error.name ? this.renderErrorDetail(t('errorName', [error.name])) : null} {error.stack ? this.renderErrorStack(t('errorStack'), error.stack) : null}
    ); } } export default ErrorPage;