add try-catch around script.main business

This commit is contained in:
2022-11-09 10:03:14 -06:00
parent 955294ae18
commit e701ae0ea3
2 changed files with 8 additions and 9 deletions

View File

@ -90,10 +90,14 @@ public class QJavaScriptExecutor implements QCodeExecutor
{
%s
if(script && script.main)
try
{
return (script.main());
if(script && script.main)
{
return (script.main());
}
}
catch(e) { }
})();
""".formatted(code);

View File

@ -108,16 +108,11 @@ class ExecuteCodeActionTest
{
OneTestOutput oneTestOutput = testOne(4, """
var script = (function (exports) {
function cooling() {
function main() {
output.setD(7);
return (output);
}
cooling();
exports.cooling = cooling;
exports.main = main;
return exports;
})({});
""");