From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [94.100.177.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9B3C24696C3 for ; Sun, 12 Apr 2020 23:13:33 +0300 (MSK) From: Vladislav Shpilevoy Date: Sun, 12 Apr 2020 22:13:27 +0200 Message-Id: <4c318477f31ba41d213a70ac75370016fcef0d9f.1586722379.git.v.shpilevoy@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/4] box: improve built-in module load panic message List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, alexander.turenko@tarantool.org 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)