mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: Add plugin info when the app crashes
This commit is contained in:
parent
108b5b4cdc
commit
de035dca39
@ -1,14 +1,53 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import versionInfo from '@joplin/lib/versionInfo';
|
import versionInfo from '@joplin/lib/versionInfo';
|
||||||
|
import PluginService from '@joplin/lib/services/plugins/PluginService';
|
||||||
|
import Setting from '@joplin/lib/models/Setting';
|
||||||
const packageInfo = require('../packageInfo.js');
|
const packageInfo = require('../packageInfo.js');
|
||||||
const ipcRenderer = require('electron').ipcRenderer;
|
const ipcRenderer = require('electron').ipcRenderer;
|
||||||
|
|
||||||
export default class ErrorBoundary extends React.Component {
|
interface ErrorInfo {
|
||||||
|
componentStack: string;
|
||||||
|
}
|
||||||
|
|
||||||
state: any = { error: null, errorInfo: null };
|
interface PluginInfo {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
enabled: boolean;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
|
||||||
componentDidCatch(error: any, errorInfo: any) {
|
interface State {
|
||||||
this.setState({ error: error, errorInfo: errorInfo });
|
error: Error;
|
||||||
|
errorInfo: ErrorInfo;
|
||||||
|
pluginInfos: PluginInfo[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {}
|
||||||
|
|
||||||
|
export default class ErrorBoundary extends React.Component<Props, State> {
|
||||||
|
|
||||||
|
public state: State = { error: null, errorInfo: null, pluginInfos: [] };
|
||||||
|
|
||||||
|
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
||||||
|
const pluginInfos: PluginInfo[] = [];
|
||||||
|
try {
|
||||||
|
const service = PluginService.instance();
|
||||||
|
const pluginSettings = service.unserializePluginSettings(Setting.value('plugins.states'));
|
||||||
|
for (const pluginId in pluginSettings) {
|
||||||
|
const plugin = PluginService.instance().pluginById(pluginId);
|
||||||
|
|
||||||
|
pluginInfos.push({
|
||||||
|
id: pluginId,
|
||||||
|
name: plugin.manifest.name,
|
||||||
|
enabled: pluginSettings[pluginId].enabled,
|
||||||
|
version: plugin.manifest.version,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Could not get plugin info:', error);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({ error, errorInfo, pluginInfos });
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -40,6 +79,15 @@ export default class ErrorBoundary extends React.Component {
|
|||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (this.state.pluginInfos.length) {
|
||||||
|
output.push(
|
||||||
|
<section key="pluginSettings">
|
||||||
|
<h2>Plugins</h2>
|
||||||
|
<pre>{JSON.stringify(this.state.pluginInfos, null, 4)}</pre>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.state.error.stack) {
|
if (this.state.error.stack) {
|
||||||
output.push(
|
output.push(
|
||||||
<section key="stacktrace">
|
<section key="stacktrace">
|
||||||
|
Loading…
Reference in New Issue
Block a user