import variables from 'modules/variables'; import { PureComponent } from 'react'; import { MdErrorOutline } from 'react-icons/md'; import { captureException } from '@sentry/react'; export default class ErrorBoundary extends PureComponent { constructor(props) { super(props); this.state = { error: false, errorData: '', showReport: true, }; } static getDerivedStateFromError(error) { console.log(error); variables.stats.postEvent('modal', 'Error occurred'); return { error: true, errorData: error, }; } reportError() { captureException(this.state.errorData); this.setState({ showReport: false, }); } render() { if (this.state.error) { return (
{variables.getMessage('modals.main.error_boundary.title')} {variables.getMessage('modals.main.error_boundary.message')}
{this.state.showReport ? ( ) : ( {variables.getMessage('modals.main.error_boundary.sent')} )}
); } return this.props.children; } }