From 90544e7c738d788defe838e77547454fce6bf9cd Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Sat, 28 Dec 2024 15:30:23 +0100 Subject: [PATCH] Fix infinite loop not being properly caught, Closes #28 --- .../cyclops/integratedscripting/api/network/IScript.java | 4 +++- .../integratedscripting/core/network/GraalScript.java | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/cyclops/integratedscripting/api/network/IScript.java b/src/main/java/org/cyclops/integratedscripting/api/network/IScript.java index 62ce7c4f..9b11205e 100644 --- a/src/main/java/org/cyclops/integratedscripting/api/network/IScript.java +++ b/src/main/java/org/cyclops/integratedscripting/api/network/IScript.java @@ -1,5 +1,7 @@ package org.cyclops.integratedscripting.api.network; +import org.cyclops.integrateddynamics.api.evaluate.EvaluationException; + import javax.annotation.Nullable; /** @@ -14,7 +16,7 @@ public interface IScript { * @return The member, or null if it does not exist. */ @Nullable - public IScriptMember getMember(String memberName); + public IScriptMember getMember(String memberName) throws EvaluationException; /** * Register a listener that will be invoked when this script gets invalidated. diff --git a/src/main/java/org/cyclops/integratedscripting/core/network/GraalScript.java b/src/main/java/org/cyclops/integratedscripting/core/network/GraalScript.java index f0dcbd52..32ff4aae 100644 --- a/src/main/java/org/cyclops/integratedscripting/core/network/GraalScript.java +++ b/src/main/java/org/cyclops/integratedscripting/core/network/GraalScript.java @@ -45,8 +45,13 @@ public GraalScript(Context graalContext, Value graalValue, @Nullable @Override - public IScriptMember getMember(String memberName) { - Value member = this.graalValue.getMember(memberName); + public IScriptMember getMember(String memberName) throws EvaluationException { + Value member; + try { + member = this.graalValue.getMember(memberName); + } catch (PolyglotException e) { + throw ScriptHelpers.getEvaluationExceptionFactory(disk, path, memberName).createError(e.getMessage()); + } return member == null ? null : new GraalScript(this.graalContext, member, this.addInvalidationListener, this.removeInvalidationListener, disk, path, memberName); }