Browse Source

break on exception thrown

Nicolas Cannasse 7 years ago
parent
commit
1e5545e611
1 changed files with 3 additions and 0 deletions
  1. 3 0
      hxd/System.hl.hx

+ 3 - 0
hxd/System.hl.hx

@@ -113,11 +113,14 @@ class System {
 	}
 	}
 
 
 	static function runMainLoop() {
 	static function runMainLoop() {
+		var reportError = function(e) reportError(e);
 		while( true ) {
 		while( true ) {
 			try {
 			try {
+				hl.Api.setErrorHandler(reportError); // set exception trap
 				@:privateAccess haxe.MainLoop.tick();
 				@:privateAccess haxe.MainLoop.tick();
 				if( !mainLoop() ) break;
 				if( !mainLoop() ) break;
 			} catch( e : Dynamic ) {
 			} catch( e : Dynamic ) {
+				hl.Api.setErrorHandler(null);
 				reportError(e);
 				reportError(e);
 			}
 			}
 		}
 		}