mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-27 12:56:01 +01:00
560be4b4e3
Any error caught during a React component render or lifecycle method will now be caught by the top-level error boundary, which shows the user this new error page. The error page will display a simple error message, and will show the details of the error in a collapsible section. The caught error is also reported to Sentry. In development the error will be re-thrown to make it easier to see on the console, but it is not re-thrown in production.
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
import React, { PureComponent } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import { Provider } from 'react-redux'
|
|
import { HashRouter } from 'react-router-dom'
|
|
import * as Sentry from '@sentry/browser'
|
|
import ErrorPage from './error'
|
|
import Routes from './routes'
|
|
import I18nProvider from '../helpers/higher-order-components/i18n-provider'
|
|
import MetaMetricsProvider from '../helpers/higher-order-components/metametrics/metametrics.provider'
|
|
|
|
class Index extends PureComponent {
|
|
state = {}
|
|
|
|
static getDerivedStateFromError (error) {
|
|
return { error }
|
|
}
|
|
|
|
componentDidCatch (error) {
|
|
Sentry.captureException(error)
|
|
}
|
|
|
|
render () {
|
|
const { error, errorId } = this.state
|
|
const { store } = this.props
|
|
|
|
if (error) {
|
|
return (
|
|
<Provider store={store}>
|
|
<I18nProvider>
|
|
<ErrorPage
|
|
error={error}
|
|
errorId={errorId}
|
|
/>
|
|
</I18nProvider>
|
|
</Provider>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<Provider store={store}>
|
|
<HashRouter hashType="noslash">
|
|
<MetaMetricsProvider>
|
|
<I18nProvider>
|
|
<Routes />
|
|
</I18nProvider>
|
|
</MetaMetricsProvider>
|
|
</HashRouter>
|
|
</Provider>
|
|
)
|
|
}
|
|
}
|
|
|
|
Index.propTypes = {
|
|
store: PropTypes.object,
|
|
}
|
|
|
|
export default Index
|