import * as React from 'react' import SentimentDissatisfied from '@mui/icons-material/SentimentDissatisfied' import Warning from '@mui/icons-material/Warning' import { Theme } from '@mui/material/styles' import { withStyles } from '@mui/styles' import { Button, Modal, Paper, Toolbar, Typography } from '@mui/material' import PersistentStorage from '../utils/PersistentStorage' interface State { error?: Error } interface Props { classes: any children?: React.ReactNode } class ErrorBoundary extends React.PureComponent { public static getDerivedStateFromError(error: Error) { return { error } } constructor(props: Props) { super(props) this.state = {} } private restart = () => { window.location.reload() } private clearStorage = () => { PersistentStorage.clear() window.location.reload() } public componentDidCatch(error: Error, errorInfo: any) { // electronRendererTelemetry.trackError(error) console.log('did catch', error) } public render() { if (!this.state.error) { return this.props.children } const { classes } = this.props return ( Oooooops! I hoped that you would never see this window, but MQTT-Explorer had an unexpected error.
            {this.state.error.stack}
          
Please report this issue with a short description of what happened to {' '} https://github.com/thomasnordquist/MQTT-Explorer/issues
) } } const styles = (theme: Theme) => ({ button: { margin: '0 8px 0 8px', }, root: { minWidth: 550, maxWidth: 650, backgroundColor: theme.palette.background.default, margin: '10vh auto auto auto', padding: theme.spacing(2), outline: 'none', }, title: { color: theme.palette.text.primary, margin: '0', textAlign: 'center' as const, }, textColor: { color: theme.palette.text.primary, userSelect: 'all' as const, }, centered: { textAlign: 'center' as const, }, buttonPositioning: { textAlign: 'center' as const, marginTop: theme.spacing(2), }, }) export default withStyles(styles)(ErrorBoundary)