From a05ff5d30ebe47cbaea9acbe0ca440fbef596713 Mon Sep 17 00:00:00 2001 From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Date: Sun, 12 Apr 2020 18:16:27 +0200 Subject: [PATCH] box: improve built-in module load panic message Box built-in modules, such as session, tuple, schema, etc, were loaded using luaL_loadbuffer() + lua_call(). Error of the former call was handled properly with a panic message describing the problem. But if lua_call() failed, it resulted into 'unknown exception' in main.cc. Not very helpful. Now it is lua_pcall(), and the error message is included into the panic() message. That helps in debug, when something is being changed in the box modules. --- src/box/lua/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/box/lua/init.c b/src/box/lua/init.c index 63e8b8216e..9db740de6a 100644 --- a/src/box/lua/init.c +++ b/src/box/lua/init.c @@ -432,10 +432,10 @@ box_lua_init(struct lua_State *L) const char *modsrc = *(s + 1); const char *modfile = lua_pushfstring(L, "@builtin/%s.lua", modname); - if (luaL_loadbuffer(L, modsrc, strlen(modsrc), modfile)) + if (luaL_loadbuffer(L, modsrc, strlen(modsrc), modfile) != 0 || + lua_pcall(L, 0, 0, 0) != 0) panic("Error loading Lua module %s...: %s", modname, lua_tostring(L, -1)); - lua_call(L, 0, 0); lua_pop(L, 1); /* modfile */ } -- GitLab