import * as React from 'react';
import versionInfo from 'lib/versionInfo';
const packageInfo = require('../packageInfo.js');
const ipcRenderer = require('electron').ipcRenderer;
export default class ErrorBoundary extends React.Component {
state:any = { error: null, errorInfo: null };
componentDidCatch(error:any, errorInfo:any) {
this.setState({ error: error, errorInfo: errorInfo });
}
componentDidMount() {
const onAppClose = () => {
ipcRenderer.send('asynchronous-message', 'appCloseReply', {
canClose: true,
});
};
ipcRenderer.on('appClose', onAppClose);
}
render() {
if (this.state.error) {
try {
const output = [];
output.push(
{this.state.error.message}Message
Version info
{versionInfo(packageInfo).message}
Stack trace
{this.state.error.stack}
Component stack
{this.state.errorInfo.componentStack}
Joplin encountered a fatal error and could not continue. To report the error, please copy the *entire content* of this page and post it on Joplin forum or GitHub.
{output}