Browse Source

Console: allow override doCall(), for example handle try/catch differently

trethaller 4 years ago
parent
commit
f7cc42761a
1 changed files with 7 additions and 2 deletions
  1. 7 2
      h2d/Console.hx

+ 7 - 2
h2d/Console.hx

@@ -81,6 +81,7 @@ class Console #if !macro extends h2d.Object #end {
 	var logs : Array<String>;
 	var logs : Array<String>;
 	var logIndex:Int;
 	var logIndex:Int;
 	var curCmd:String;
 	var curCmd:String;
+	var errorColor = 0xC00000;
 
 
 	/**
 	/**
 		The text character which should be pressed in order to automatically show console input.
 		The text character which should be pressed in order to automatically show console input.
@@ -392,7 +393,6 @@ class Console #if !macro extends h2d.Object #end {
 		logs.push(command);
 		logs.push(command);
 		logIndex = -1;
 		logIndex = -1;
 
 
-		var errorColor = 0xC00000;
 
 
 		var args = [];
 		var args = [];
 		var c = '';
 		var c = '';
@@ -508,8 +508,13 @@ class Console #if !macro extends h2d.Object #end {
 				}
 				}
 			}
 			}
 		}
 		}
+
+		doCall(cmd.callb, vargs);
+	}
+
+	function doCall( callb : Dynamic, vargs : Array<Dynamic> ) {
 		try {
 		try {
-			Reflect.callMethod(null, cmd.callb, vargs);
+			Reflect.callMethod(null, callb, vargs);
 		} catch( e : String ) {
 		} catch( e : String ) {
 			log('ERROR $e', errorColor);
 			log('ERROR $e', errorColor);
 		}
 		}