From b0d52fe1180bf4852c6d644f646cbb2dfbfe30f7 Mon Sep 17 00:00:00 2001 From: James Roseborough Date: Mon, 30 Dec 2013 23:58:02 +0000 Subject: [PATCH] Let errors thrown in debug hooks bubble up to the running coroutine. --- README.html | 1 + src/core/org/luaj/vm2/LuaError.java | 1 - src/core/org/luaj/vm2/LuaThread.java | 2 -- src/core/org/luaj/vm2/lib/DebugLib.java | 7 +++++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.html b/README.html index dc7567fd..52a5b5d1 100644 --- a/README.html +++ b/README.html @@ -909,6 +909,7 @@ Files are no longer hosted at LuaForge.
  • Fix os.time() to return a number of seconds.
  • Implement formatting with os.date(), and table argument for os.time().
  • Refactor APIs related to compiling and loading scripts.
  • +
  • Let errors thrown in debug hooks bubble up to the running coroutine.
  • diff --git a/src/core/org/luaj/vm2/LuaError.java b/src/core/org/luaj/vm2/LuaError.java index 7c6c5540..cbe68eb8 100644 --- a/src/core/org/luaj/vm2/LuaError.java +++ b/src/core/org/luaj/vm2/LuaError.java @@ -21,7 +21,6 @@ ******************************************************************************/ package org.luaj.vm2; -import org.luaj.vm2.lib.DebugLib; /** * RuntimeException that is thrown and caught in response to a lua error. diff --git a/src/core/org/luaj/vm2/LuaThread.java b/src/core/org/luaj/vm2/LuaThread.java index a9450437..0bee9bb8 100644 --- a/src/core/org/luaj/vm2/LuaThread.java +++ b/src/core/org/luaj/vm2/LuaThread.java @@ -24,8 +24,6 @@ package org.luaj.vm2; import java.lang.ref.WeakReference; -import org.luaj.vm2.lib.DebugLib; - /** * Subclass of {@link LuaValue} that implements * a lua coroutine thread using Java Threads. diff --git a/src/core/org/luaj/vm2/lib/DebugLib.java b/src/core/org/luaj/vm2/lib/DebugLib.java index e6e23947..860771c9 100644 --- a/src/core/org/luaj/vm2/lib/DebugLib.java +++ b/src/core/org/luaj/vm2/lib/DebugLib.java @@ -25,6 +25,7 @@ import org.luaj.vm2.Globals; import org.luaj.vm2.Lua; import org.luaj.vm2.LuaBoolean; import org.luaj.vm2.LuaClosure; +import org.luaj.vm2.LuaError; import org.luaj.vm2.LuaFunction; import org.luaj.vm2.LuaNil; import org.luaj.vm2.LuaNumber; @@ -432,8 +433,10 @@ public class DebugLib extends TwoArgFunction { t.inhook = true; try { t.hookfunc.call(type, arg); - } catch (Exception e) { - e.printStackTrace(); + } catch (LuaError e) { + throw e; + } catch (RuntimeException e) { + throw new LuaError(e); } finally { t.inhook = false; }