瀏覽代碼

Merge pull request #101 from Akeit0/fix-error-message

Fix: unintended `index out of range exception` on other exception
Akeit0 8 月之前
父節點
當前提交
9dc2d2c16b
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/Lua/Runtime/LuaVirtualMachine.cs

+ 3 - 2
src/Lua/Runtime/LuaVirtualMachine.cs

@@ -932,16 +932,17 @@ public static partial class LuaVirtualMachine
         }
         }
         catch (Exception e)
         catch (Exception e)
         {
         {
-            context.PopOnTopCallStackFrames();
             context.State.CloseUpValues(context.Thread, context.FrameBase);
             context.State.CloseUpValues(context.Thread, context.FrameBase);
             LuaValueArrayPool.Return1024(context.ResultsBuffer, true);
             LuaValueArrayPool.Return1024(context.ResultsBuffer, true);
             if (e is not LuaRuntimeException)
             if (e is not LuaRuntimeException)
             {
             {
-                var newException = new LuaRuntimeException(GetTracebacks(ref context), e);
+                var newException = new LuaRuntimeException(context.State.GetTraceback(), e);
+                context.PopOnTopCallStackFrames();
                 context = default;
                 context = default;
                 throw newException;
                 throw newException;
             }
             }
 
 
+            context.PopOnTopCallStackFrames();
             throw;
             throw;
         }
         }
     }
     }