You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.1 KiB
80 lines
2.1 KiB
4 years ago
|
import React, { PureComponent } from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
4 years ago
|
import { getEnvironmentType } from '../../../app/scripts/lib/util';
|
||
|
import { ENVIRONMENT_TYPE_POPUP } from '../../../shared/constants/app';
|
||
5 years ago
|
|
||
|
class ErrorPage extends PureComponent {
|
||
|
static contextTypes = {
|
||
|
t: PropTypes.func.isRequired,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
|
static propTypes = {
|
||
|
error: PropTypes.object.isRequired,
|
||
4 years ago
|
};
|
||
5 years ago
|
|
||
4 years ago
|
renderErrorDetail(content) {
|
||
5 years ago
|
return (
|
||
|
<li>
|
||
4 years ago
|
<p>{content}</p>
|
||
5 years ago
|
</li>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
renderErrorStack(title, stack) {
|
||
5 years ago
|
return (
|
||
|
<li>
|
||
4 years ago
|
<span>{title}</span>
|
||
|
<pre className="error-page__stack">{stack}</pre>
|
||
5 years ago
|
</li>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
|
|
||
4 years ago
|
render() {
|
||
4 years ago
|
const { error } = this.props;
|
||
|
const { t } = this.context;
|
||
5 years ago
|
|
||
4 years ago
|
const isPopup = getEnvironmentType() === ENVIRONMENT_TYPE_POPUP;
|
||
4 years ago
|
const supportLink = (
|
||
|
<a
|
||
|
target="_blank"
|
||
|
key="metamaskSupportLink"
|
||
|
rel="noopener noreferrer"
|
||
|
href="https://metamask.zendesk.com/hc/en-us/requests/new"
|
||
|
>
|
||
|
<span className="error-page__link-text">{this.context.t('here')}</span>
|
||
|
</a>
|
||
|
);
|
||
|
const message = isPopup
|
||
|
? t('errorPagePopupMessage', [supportLink])
|
||
|
: t('errorPageMessage', [supportLink]);
|
||
5 years ago
|
|
||
|
return (
|
||
|
<section className="error-page">
|
||
4 years ago
|
<h1 className="error-page__header">{t('errorPageTitle')}</h1>
|
||
4 years ago
|
<h2 className="error-page__subheader">{message}</h2>
|
||
5 years ago
|
<section className="error-page__details">
|
||
|
<details>
|
||
4 years ago
|
<summary>{t('errorDetails')}</summary>
|
||
5 years ago
|
<ul>
|
||
4 years ago
|
{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}
|
||
5 years ago
|
</ul>
|
||
|
</details>
|
||
|
</section>
|
||
|
</section>
|
||
4 years ago
|
);
|
||
5 years ago
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
export default ErrorPage;
|