[Tarantool-patches] [PATCH 1/4] box: improve built-in module load panic message

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sun Apr 12 23:13:27 MSK 2020


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 63e8b8216..9db740de6 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 */
 	}
 
-- 
2.21.1 (Apple Git-122.3)



More information about the Tarantool-patches mailing list