better lua error reporting
This commit is contained in:
parent
c89841bb83
commit
da79ebf048
2 changed files with 6 additions and 8 deletions
|
@ -649,7 +649,7 @@ struct EditorWindow : AssetEditorWindow {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool gatherRequires(Span<const u8> src, Lumix::Array<Path>& dependencies) {
|
static bool gatherRequires(Span<const u8> src, Lumix::Array<Path>& dependencies, const Path& path) {
|
||||||
lua_State* L = luaL_newstate();
|
lua_State* L = luaL_newstate();
|
||||||
|
|
||||||
auto reg_dep = [](lua_State* L) -> int {
|
auto reg_dep = [](lua_State* L) -> int {
|
||||||
|
@ -692,8 +692,10 @@ static bool gatherRequires(Span<const u8> src, Lumix::Array<Path>& dependencies)
|
||||||
lua_insert(L, -2); // new_g, meta
|
lua_insert(L, -2); // new_g, meta
|
||||||
lua_setmetatable(L, -2); //new_g
|
lua_setmetatable(L, -2); //new_g
|
||||||
|
|
||||||
bool errors = LuaWrapper::luaL_loadbuffer(L, (const char*)src.m_begin, src.length(), "gather_requires"); // new_g, fn
|
bool errors = LuaWrapper::luaL_loadbuffer(L, (const char*)src.m_begin, src.length(), path.c_str()); // new_g, fn
|
||||||
if (errors) {
|
if (errors) {
|
||||||
|
const char* msg = lua_tostring(L, -1);
|
||||||
|
logError(msg);
|
||||||
lua_close(L);
|
lua_close(L);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -724,7 +726,7 @@ struct AssetPlugin : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
|
||||||
if (!fs.getContentSync(src, src_data)) return false;
|
if (!fs.getContentSync(src, src_data)) return false;
|
||||||
|
|
||||||
Array<Path> deps(m_app.getAllocator());
|
Array<Path> deps(m_app.getAllocator());
|
||||||
if (!gatherRequires(src_data, deps)) return false;
|
if (!gatherRequires(src_data, deps, src)) return false;
|
||||||
|
|
||||||
OutputMemoryStream out(m_app.getAllocator());
|
OutputMemoryStream out(m_app.getAllocator());
|
||||||
out.write(deps.size());
|
out.write(deps.size());
|
||||||
|
|
|
@ -2408,11 +2408,7 @@ public:
|
||||||
|
|
||||||
lua_pushvalue(L, -3); // [lua_event, environment, func, lua_event]
|
lua_pushvalue(L, -3); // [lua_event, environment, func, lua_event]
|
||||||
|
|
||||||
if (lua_pcall(L, 1, 0, 0) != 0)// [lua_event, environment]
|
LuaWrapper::pcall(L, 1, 0); // [lua_event, environment]
|
||||||
{
|
|
||||||
logError(lua_tostring(L, -1));
|
|
||||||
lua_pop(L, 1); // []
|
|
||||||
}
|
|
||||||
lua_pop(L, 2); // []
|
lua_pop(L, 2); // []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue