Add exception handling during trigger command (#179)

This commit is contained in:
phaitonican
2020-09-08 17:53:58 +02:00
committed by GitHub
parent 3a112f2f79
commit c68c91faf8

View File

@@ -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();