[ErrorHandler] Rewrite stack getting and other minor parts
This commit is contained in:
parent
316b458eee
commit
da406d0fe0
1 changed files with 9 additions and 14 deletions
|
@ -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) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue