@@ -10,7 +10,8 @@ const chokidar = require('chokidar');
1010const os = require ( 'os' ) ;
1111
1212const moment = require ( 'moment' ) ;
13- var log = require ( 'electron-log' ) ;
13+ const log = require ( 'electron-log' ) ;
14+
1415log . transports . file . appName = 'gtt-taskbar' ;
1516
1617let gtt = new events . EventEmitter ( ) ,
@@ -26,11 +27,6 @@ gtt._app = app;
2627gtt . _version = '0.2.4' ;
2728gtt . _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-
3430gtt . _api = new Base ( gtt . _config ) ;
3531gtt . _tasks = new Tasks ( gtt . _config ) ;
3632gtt . _paused = false ;
@@ -42,12 +38,14 @@ gtt._offline = false;
4238gtt . _platform = { darwin : 'mac' , linux : 'linux' , win32 : 'win' } [ os . platform ( ) ] ;
4339gtt . _iconPath = path . join ( __dirname , 'images/' , gtt . _platform == 'mac' ? 'mac' : 'default' ) ;
4440
41+ // Fix app not closing on Mac
4542app . on ( 'window-all-closed' , ( ) => {
4643 if ( process . platform != 'darwin' ) {
4744 app . quit ( ) ;
4845 }
4946} ) ;
5047
48+ // Fix transparency issues on Linux
5149app . disableHardwareAcceleration ( ) ;
5250
5351app . 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) => {
551549ipcMain . 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