OpenAsar/src/errorHandler.js

30 lines
752 B
JavaScript
Raw Normal View History

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