Add TryCatch to catch errors in scripting also when called directly from a JSScriptFunction