
global.process.removeAllListeners();

global.process.on( "uncaughtException", function( err ) {
	console.log( "Uncaught exception:", err );

	// do nothing if window was fully initialized
	if ( window.initialized ) { return; }

	// kill the process while not being in debug mode
	if ( !DEBUG ) {
		global.process.exit( 1 );
	}

	// open the window and dev tools
	try {
		var nwWindow = window.nwDispatcher.requireNwGui().Window.get();
		nwWindow.show();
		nwWindow.showDevTools();
	} catch ( e ) {
		console.log( "Could not initialize application window" );
		global.process.exit( 1 );
	}
});

require( "styles/app" );
require( "./app" );

@@ -94,53 +94,8 @@
 ) %7B%0A
-%09console.log( %22Uncaught exception:%22, err );%0A%0A
 %09// 
@@ -185,31 +185,48 @@
 %09// 
-kill
+show
  the 
-proces
+app window and dev tool
 s while 
 not 
@@ -221,20 +221,16 @@
 s while 
-not 
 being in
@@ -251,9 +251,8 @@
 f ( 
-!
 DEBU
@@ -262,80 +262,16 @@
  %7B%0A%09
-%09global.process.exit( 1 );%0A%09%7D%0A%0A%09// open the window and dev tools%0A
 %09try %7B%0A
+%09
 %09%09va
@@ -287,41 +287,26 @@
 w = 
-window.nwDispatcher.requireNwGui(
+require( %22nw.gui%22 
 ).Wi
@@ -313,24 +313,25 @@
 ndow.get();%0A
+%09
 %09%09nwWindow.s
@@ -337,16 +337,17 @@
 show();%0A
+%09
 %09%09nwWind
@@ -369,16 +369,28 @@
 ();%0A
+%09%09%09return;%0A%09
 %09%7D catch
  ( e
@@ -389,78 +389,216 @@
 atch
- 
 ( e ) %7B
+%7D
 %0A%09
-%09console.log( %22Could not initialize application window%22
+%7D%0A%0A%09// write to stderr and kill the process with error code 1%0A%09global.process.stderr.write(%5B%0A%09%09%22Could not initialize application window%22,%0A%09%09require( %22util%22 ).inspect( err ),%0A%09%09%22%22%0A%09%5D.join( %22%5Cn%22 )
  );%0A
-%09
 %09glo
@@ -624,16 +624,14 @@
  );%0A
-%09%7D%0A
 %7D);%0A%0A
+%0A
 requ

Fix global uncaughtException event listener