[ErrorHandler] Rewrite stack getting and other minor parts

This commit is contained in:
Ducko 2022-03-09 22:20:34 +00:00
parent 316b458eee
commit da406d0fe0

View file

@ -1,28 +1,23 @@
const { app, dialog } = require("electron"); const { app, dialog } = require("electron");
exports.init = () => { exports.init = () => {
process.on('uncaughtException', error => { process.on('uncaughtException', err => {
const stack = error.stack ? error.stack : String(error); const stack = err.stack ?? String(err);
const message = `Uncaught exception:\n${stack}`; console.warn(stack);
console.warn(message);
// _electron.dialog.showErrorBox('A JavaScript error occurred in the main process', message); // dialog.showErrorBox('A JavaScript error occurred in the main process', message);
}); });
log('ErrorHandler', 'Inited');
}; };
exports.fatal = (err) => { exports.fatal = (err) => {
const options = { log('ErrorHandler', 'Fatal:', err);
dialog.showMessageBox(null, {
type: 'error', type: 'error',
message: 'A fatal Javascript error occured', message: 'A fatal Javascript error occured',
detail: err && err.stack ? err.stack : String(err) detail: err?.stack ?? String(err)
}; }).then(() => app.quit());
dialog.showMessageBox(null, options).then(() => app.quit());
log('ErrorHandler', 'Fatal:', err);
}; };
exports.handled = (err) => { exports.handled = (err) => {