Skip to content

Commit b6d50ea

Browse files
committed
Fix ESI bug, add error reporting
1 parent 93ddcd9 commit b6d50ea

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

src/index.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const chokidar = require('chokidar');
1010
const os = require('os');
1111

1212
const moment = require('moment');
13-
var log = require('electron-log');
13+
const log = require('electron-log');
14+
1415
log.transports.file.appName = 'gtt-taskbar';
1516

1617
let gtt = new events.EventEmitter(),
@@ -26,11 +27,6 @@ gtt._app = app;
2627
gtt._version = '0.2.4';
2728
gtt._config = new Config(__dirname);
2829

29-
if (gtt._config.get('error-reporting')) {
30-
var Raven = require('raven');
31-
Raven.config('https://[email protected]/1218774').install();
32-
}
33-
3430
gtt._api = new Base(gtt._config);
3531
gtt._tasks = new Tasks(gtt._config);
3632
gtt._paused = false;
@@ -42,12 +38,14 @@ gtt._offline = false;
4238
gtt._platform = {darwin: 'mac', linux: 'linux', win32: 'win'}[os.platform()];
4339
gtt._iconPath = path.join(__dirname, 'images/', gtt._platform == 'mac' ? 'mac' : 'default');
4440

41+
// Fix app not closing on Mac
4542
app.on('window-all-closed', () => {
4643
if (process.platform != 'darwin') {
4744
app.quit();
4845
}
4946
});
5047

48+
// Fix transparency issues on Linux
5149
app.disableHardwareAcceleration();
5250

5351
app.on('ready', () => {
@@ -400,7 +398,7 @@ gtt._send = (key, val) => {
400398
gtt._dump(`ipc main send: ${key}, ${val}`);
401399
}
402400

403-
if(trayWindow)
401+
if (trayWindow)
404402
trayWindow.webContents.send(key, val);
405403
};
406404

@@ -551,3 +549,23 @@ ipcMain.on('cache-get', (event, key) => {
551549
ipcMain.on('cache-set', (event, {key, data}) => {
552550
gtt.cache.set(key, data);
553551
});
552+
553+
process.on('uncaughtException', function (e) {
554+
if (dialog.showMessageBox(null, {
555+
type: "error",
556+
title: "Error",
557+
message: "gtt encountered an error and was terminated!",
558+
detail: "You can send an error report containing the exception message and a stack trace to help improve gtt. No personal information will be transfered.",
559+
buttons: ["Send error report", "Don't send report"]
560+
}) === 0 || gtt._config.get('error-reporting')) {
561+
console.log("Sending error report ...");
562+
var Raven = require('raven');
563+
Raven.config('https://[email protected]/1218774').install();
564+
Raven.captureException(e);
565+
console.log("done.");
566+
setTimeout(process.exit, 5000);
567+
return;
568+
}
569+
570+
throw e;
571+
});

0 commit comments

Comments
 (0)