Browse Source

Add exception handling during trigger command (#179)

phaitonican 5 years ago
parent
commit
c68c91faf8
1 changed files with 16 additions and 8 deletions
  1. 16 8
      src/debugger/commands/command_parser.ts

+ 16 - 8
src/debugger/commands/command_parser.ts

@@ -29,12 +29,6 @@ export class CommandParser {
 				return new CommandMessageInspectObject();
 			},
 		],
-		[
-			"message:scene_tree",
-			function () {
-				return new CommandMessageSceneTree();
-			},
-		],
 		[
 			"stack_dump",
 			function () {
@@ -126,9 +120,23 @@ export class CommandParser {
 				this.parameters.push(dataset.shift());
 				if (this.current_command.param_count !== -1) {
 					if (this.current_command.param_count === this.parameters.length) {
-						this.current_command.trigger(this.parameters);
-						this.current_command = undefined;
+						try {
+							this.current_command.trigger(this.parameters);
+						} catch (e) {
+							// FIXME: Catch exception during trigger command: TypeError: class_name.replace is not a function
+							// class_name is the key of Mediator.inspect_callbacks
+							console.error("Catch exception during trigger command: " + e);
+						} finally {
+							this.current_command = undefined;
+							this.parameters = [];
+						}
+					} else if(this.current_command.param_count < this.parameters.length) {
+						// we debugged that an exception occures during this.current_command.trigger(this.parameters)
+						// because we do not understand the root cause of the exception, we set the current command to undefined
+						// to avoid a infinite loop of parse_message(...)
+						this.current_command = undefined
 						this.parameters = [];
+						console.log("Exception not catched. Reset current_command to avoid infinite loop.")
 					}
 				} else {
 					this.current_command.param_count = this.parameters.shift();