/* * Passes errors (argument e) to the Lua interpreter */ internal void throwError(IntPtr luaState, object e) { // If the argument is a mere string, we are free to add extra info to it (as opposed to some private C# exception object or somesuch, which we just pass up) if (e is string) { // We use this to remove anything pushed by luaL_where int oldTop = LuaDLL.lua_gettop(luaState); // Stack frame #1 is our C# wrapper, so not very interesting to the user // Stack frame #2 must be the lua code that called us, so that's what we want to use LuaDLL.luaL_where(luaState, 2); object[] curlev = popValues(luaState, oldTop); // Debug.WriteLine(curlev); if (curlev.Length > 0) { e = curlev[0].ToString() + e; } } push(luaState, e); LuaDLL.lua_error(luaState); }