Add exception handlers in places where scripts are invoked. This should lead to slightly nicer error messages.

This commit is contained in:
Twan van Laarhoven
2020-05-22 00:30:18 +02:00
parent 8b91cd8804
commit c9c7a958ae
5 changed files with 38 additions and 14 deletions
+6 -2
View File
@@ -229,8 +229,12 @@ size_t DropDownChoiceList::selection() const {
return 0;
} else {
// run default script to find out what the default choice would be
String default_choice = field().default_script.invoke( cve.viewer.getContext() )->toString();
default_id = group->choiceId(default_choice);
try {
String default_choice = field().default_script.invoke( cve.viewer.getContext() )->toString();
default_id = group->choiceId(default_choice);
} catch (ScriptError const& e) {
handle_error(ScriptError(e.what() + _("\n in default script for '") + field().name + _("'")));
}
}
}
// item corresponding to id