From 611be55bbbf205931c4ab35e0d24beb354b6b4b7 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:15:38 +0200 Subject: [PATCH] fix: should throw engine exceptions, not java exceptions --- .../jscript/runtime/values/functions/FunctionValue.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/topchetoeu/jscript/runtime/values/functions/FunctionValue.java b/src/main/java/me/topchetoeu/jscript/runtime/values/functions/FunctionValue.java index 3038536..5b3fcc7 100644 --- a/src/main/java/me/topchetoeu/jscript/runtime/values/functions/FunctionValue.java +++ b/src/main/java/me/topchetoeu/jscript/runtime/values/functions/FunctionValue.java @@ -7,6 +7,7 @@ import java.util.List; import me.topchetoeu.jscript.common.environment.Environment; import me.topchetoeu.jscript.runtime.debug.DebugContext; +import me.topchetoeu.jscript.runtime.exceptions.EngineException; import me.topchetoeu.jscript.runtime.values.KeyCache; import me.topchetoeu.jscript.runtime.values.Member; import me.topchetoeu.jscript.runtime.values.Value; @@ -55,11 +56,11 @@ public abstract class FunctionValue extends ObjectValue { @Override public String toString() { return String.format("function %s(...)", name); } @Override public Value apply(Environment env, Value self, Value... args) { - if (!enableApply) throw new RuntimeException("Function cannot be applied"); + if (!enableApply) throw EngineException.ofType("Function cannot be applied"); return onCall(env, false, self, args); } @Override public Value construct(Environment env, Value self, Value... args) { - if (!enableConstruct) throw new RuntimeException("Function cannot be constructed"); + if (!enableConstruct) throw EngineException.ofType("Function cannot be constructed"); return onCall(env, true, self, args); }