Show uncaughtException as an internal error and quit the app

This commit is contained in:
Yuya Ochiai
2017-10-17 00:54:56 +09:00
parent 2a9ecaf119
commit a9af3c2dcb
2 changed files with 77 additions and 10 deletions

View File

@@ -10,15 +10,18 @@ const {
systemPreferences,
session
} = require('electron');
const os = require('os');
const path = require('path');
const isDev = require('electron-is-dev');
const installExtension = require('electron-devtools-installer');
const squirrelStartup = require('./main/squirrelStartup');
const CriticalErrorHandler = require('./main/CriticalErrorHandler');
const protocols = require('../electron-builder.json').protocols;
process.on('uncaughtException', (error) => {
console.error(error);
});
const criticalErrorHandler = new CriticalErrorHandler();
process.on('uncaughtException', criticalErrorHandler.processUncaughtExceptionHandler.bind(criticalErrorHandler));
global.willAppQuit = false;
@@ -27,9 +30,6 @@ if (squirrelStartup()) {
global.willAppQuit = true;
}
const os = require('os');
const path = require('path');
var settings = require('./common/settings');
var certificateStore = require('./main/certificateStore').load(path.resolve(app.getPath('userData'), 'certificate.json'));
const {createMainWindow} = require('./main/mainWindow');
@@ -304,6 +304,10 @@ app.on('certificate-error', (event, webContents, url, error, certificate, callba
}
});
app.on('gpu-process-crashed', () => {
throw new Error('The GPU process has crached');
});
const loginCallbackMap = new Map();
ipcMain.on('login-credentials', (event, request, user, password) => {
@@ -392,11 +396,10 @@ app.on('ready', () => {
// when you should delete the corresponding element.
mainWindow = null;
});
mainWindow.on('unresponsive', () => {
console.log('The application has become unresponsive.');
});
criticalErrorHandler.setMainWindow(mainWindow);
mainWindow.on('unresponsive', criticalErrorHandler.windowUnresponsiveHandler.bind(criticalErrorHandler));
mainWindow.webContents.on('crashed', () => {
console.log('The application has crashed.');
throw new Error('webContents \'crashed\' event has been emitted');
});
ipcMain.on('notified', () => {