2019-01-17 18:00:12 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
value: true
|
|
|
|
});
|
|
|
|
exports.init = init;
|
|
|
|
exports.fatal = fatal;
|
|
|
|
|
|
|
|
var _electron = require('electron');
|
|
|
|
|
|
|
|
function isErrorSafeToSuppress(error) {
|
|
|
|
return (/attempting to call a function in a renderer window/i.test(error.message)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function init() {
|
2019-01-18 17:51:44 +00:00
|
|
|
process.on('uncaughtException', error => {
|
|
|
|
const stack = error.stack ? error.stack : String(error);
|
|
|
|
const message = `Uncaught exception:\n ${stack}`;
|
2019-01-17 18:00:12 +00:00
|
|
|
console.warn(message);
|
|
|
|
|
|
|
|
if (!isErrorSafeToSuppress(error)) {
|
|
|
|
_electron.dialog.showErrorBox('A JavaScript error occurred in the main process', message);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// show a similar error message to the error handler, except exit out the app
|
|
|
|
// after the error message has been closed
|
|
|
|
function fatal(err) {
|
|
|
|
_electron.dialog.showMessageBox({
|
|
|
|
type: 'error',
|
|
|
|
message: 'A fatal Javascript error occured',
|
|
|
|
detail: err && err.stack ? err.stack : String(err)
|
2019-01-18 17:51:44 +00:00
|
|
|
}, () => {
|
2019-01-17 18:00:12 +00:00
|
|
|
_electron.app.quit();
|
|
|
|
});
|
|
|
|
}
|