JerboaBurrow / Hop

Lightweight, cross-platform, 2D game engine | ECS; Lua Console; Physics; Tile based

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lua empty stack trace, and empty error message

Jerboa-app opened this issue · comments

commented

Fixed in #96

Requires a debug function to be inserted before calling pcall, so instead of lua_dofile we do...

           bool runFile(std::string file)
            {
                if (luaIsOk())
                {
                    lastCommandOrProgram = file;
                    lastStatus = luaL_loadfile(lua, file.c_str());
                    // location of custom error handler
                    int epos = lua_gettop(lua);
                    // push the custom handler
                    lua_pushcfunction(lua, traceback);
                    lua_insert(lua, epos);
                    // run the file passing in the handler
                    lastStatus = lastStatus || lua_pcall(lua, 0, LUA_MULTRET, epos);
                    lua_remove(lua, epos);
                    return handleErrors();
                }
                return false;
            }