Codegen better error if script not stack neutral
@@ -105,6 +105,7 @@ const compileEntityEvents = (scriptIndex, input = [], options = {}) => {
compileEventsWithScriptBuilder(scriptBuilder, input);
+ try {
if (!branch) {
if (loop && input.length > 1) {
scriptBuilder.nextFrameAwait();
@@ -127,6 +128,16 @@ const compileEntityEvents = (scriptIndex, input = [], options = {}) => {
}
return scriptBuilder.toScriptString(`script_${scriptIndex}`);
+ } catch (e) {
+ throw new Error(
+ `Compiling failed with error "${e}". ${JSON.stringify(
+ location
+ )}`
+ );
+ }
+
+ return "";
+
};
export default compileEntityEvents;
