Skip to content

Commit

Permalink
alert main process errors
Browse files Browse the repository at this point in the history
  • Loading branch information
qishibo committed Jan 5, 2022
1 parent ee7f8dd commit 53f5b74
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions pack/electron/electron-main.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow, Menu, ipcMain } = require('electron');
const { app, BrowserWindow, Menu, ipcMain, dialog } = require('electron');
const fontManager = require('./font-manager');
const winState = require('./win-state');


global.APP_ENV = (process.env.NODE_ENV === 'dev') ? 'dev' : 'production';

if (APP_ENV === 'production') {
require('./update')();
}

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;

// handle uncaught exception
process.on('uncaughtException', (err, origin) => {
if (!err) {
return;
}

dialog.showMessageBoxSync(mainWindow, {
type: 'error',
title: 'Whoops! Uncaught Exception',
message: err.stack,
detail: '\nDon\'t worry, I will fix it! 😎😎\n\n'
+ 'Submit issue to: \nhttps://github.com/qishibo/AnotherRedisDesktopManager/'
});

process.exit();
});

// auto update
if (APP_ENV === 'production') {
require('./update')();
}

function createWindow() {
// get last win stage
const lastWinStage = winState.getLastState();
Expand Down

0 comments on commit 53f5b74

Please sign in to comment.