diff --git a/src/lua/init.m b/src/lua/init.m index c2bb9b679518eb5844f87ffdbec584a0e9744215..2481ec95e56a9a5cbd1c6f9cb80e1d43072e7744 100644 --- a/src/lua/init.m +++ b/src/lua/init.m @@ -1334,6 +1334,20 @@ tarantool_lua_register_type(struct lua_State *L, const char *type_name, lua_pop(L, 1); } +static const struct luaL_reg errorlib [] = { + {NULL, NULL} +}; + +static void +tarantool_lua_error_init(struct lua_State *L) { + luaL_register(L, "box.error", errorlib); + for (int i = 0; i < tnt_error_codes_enum_MAX; i++) { + lua_pushnumber(L, i); + lua_setfield(L, -2, tnt_error_codes[i].errstr); + } + lua_pop(L, 1); +} + struct lua_State * tarantool_lua_init() { @@ -1370,6 +1384,7 @@ tarantool_lua_init() tarantool_lua_uuid_init(L); tarantool_lua_socket_init(L); tarantool_lua_session_init(L); + tarantool_lua_error_init(L); mod_lua_init(L); diff --git a/test/box/lua.result b/test/box/lua.result index 5a632589e0604caabec4db3bb329f3a884024274..8df89a104a735e7acc45ed88a3600dd7c9d055d0 100644 --- a/test/box/lua.result +++ b/test/box/lua.result @@ -13,36 +13,37 @@ lua print(' lua says: hello') lua for n in pairs(box) do print(' - box.', n) end --- - box.fiber - - box.space - - box.cfg - - box.on_reload_configuration - - box.bless_space - box.time64 - - box.uuid - - box.ipc - - box.delete + - box.auto_increment - box.counter + - box.delete - box.replace - - box.auto_increment - - box.update - box.time - - box.select_range - - box.insert - - box.select_reverse_range - - box.select + - box.update + - box.on_reload_configuration - box.info - - box.session - box.uuid_hex - - box.dostring - box.slab + - box.pack + - box.raise + - box.bless_space + - box.ipc + - box.cfg + - box.space + - box.insert + - box.uuid + - box.session + - box.select_reverse_range + - box.index + - box.dostring - box.process + - box.stat - box.select_limit + - box.select - box.flags - - box.stat - - box.index - box.unpack - - box.pack - - box.raise + - box.select_range + - box.error - box.socket ... lua box.pack()