handle unhandle exception/rejection in process level (#1210)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { app, BrowserWindow, protocol, net } from "electron";
|
||||
import { app, BrowserWindow, protocol, net, shell } from "electron";
|
||||
import path from "path";
|
||||
import fs from "fs-extra";
|
||||
import settings from "@main/settings";
|
||||
@@ -8,6 +8,8 @@ import ElectronSquirrelStartup from "electron-squirrel-startup";
|
||||
import contextMenu from "electron-context-menu";
|
||||
import { t } from "i18next";
|
||||
import { updateElectronApp, UpdateSourceType } from "update-electron-app";
|
||||
import unhandled from "electron-unhandled";
|
||||
import newGithubIssueUrl from "new-github-issue-url";
|
||||
|
||||
const logger = log.scope("main");
|
||||
|
||||
@@ -133,6 +135,43 @@ app.on("ready", async () => {
|
||||
});
|
||||
|
||||
mainWindow.init();
|
||||
|
||||
unhandled({
|
||||
showDialog: true,
|
||||
logger: logger.error,
|
||||
reportButton: (error) => {
|
||||
const url = newGithubIssueUrl({
|
||||
user: "ZuodaoTech",
|
||||
repo: "everyone-can-use-english",
|
||||
title: "Unhandled Error",
|
||||
body: `
|
||||
## Node.js error stack
|
||||
|
||||
**Message:**
|
||||
|
||||
\`\`\`
|
||||
${error.message}
|
||||
\`\`\`
|
||||
|
||||
**Stack:**
|
||||
|
||||
\`\`\`
|
||||
${error.stack}
|
||||
\`\`\`
|
||||
|
||||
**Environment:**
|
||||
|
||||
\`\`\`
|
||||
${app.name} ${app.getVersion()}
|
||||
Electron ${process.versions.electron}
|
||||
${process.platform} ${process.arch}
|
||||
Locale: ${app.getLocale()}
|
||||
\`\`\``,
|
||||
});
|
||||
|
||||
shell.openExternal(url);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
|
||||
Reference in New Issue
Block a user