From e7d1a6dfaca765e828e0565c7ced2775f6ae3195 Mon Sep 17 00:00:00 2001 From: Oj Date: Sat, 16 Apr 2022 23:53:40 +0100 Subject: [PATCH] [Chore] Revert --- src/bootstrap.js | 6 +++--- src/errorHandler.js | 27 ++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/bootstrap.js b/src/bootstrap.js index eeef06a..51de6cc 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -14,8 +14,8 @@ global.releaseChannel = buildInfo.releaseChannel; log('BuildInfo', buildInfo); -const { fatal } = require('./errorHandler'); -// process.on('uncaughtException', fatal); +const { fatal, handled, init: EHInit } = require('./errorHandler'); +EHInit(); const splash = require('./splash'); @@ -69,7 +69,7 @@ const startUpdate = async () => { inst.on('host-updated', () => autoStart.update(() => {})); inst.on('unhandled-exception', fatal); inst.on('InconsistentInstallerState', fatal); - inst.on('update-error', console.error); + inst.on('update-error', handled); require('./firstRun').do(inst); } else { diff --git a/src/errorHandler.js b/src/errorHandler.js index 6d117ad..23b59f6 100644 --- a/src/errorHandler.js +++ b/src/errorHandler.js @@ -1,8 +1,25 @@ const { app, dialog } = require("electron"); +exports.init = () => { + process.on('uncaughtException', err => { + const stack = err.stack ?? String(err); + console.warn(stack); -exports.fatal = (e) => console.log(e) || dialog.showMessageBox({ - type: 'error', - message: 'A fatal Javascript error occured', - detail: e?.stack ?? String(e) -}).then(() => app.quit()); \ No newline at end of file + // dialog.showErrorBox('A JavaScript error occurred in the main process', message); + }); +}; + + +exports.fatal = (err) => { + log('ErrorHandler', 'Fatal:', err); + + dialog.showMessageBox(null, { + type: 'error', + message: 'A fatal Javascript error occured', + detail: err?.stack ?? String(err) + }).then(() => app.quit()); +}; + +exports.handled = (err) => { + log('ErrorHandler', 'Handled:', err); +}; \ No newline at end of file