diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 20acf2b9358a5e0e39af77e0970342dc5901b56d..9804d41ffe1c8461ca2b7667df3d92bdd88fb050 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -86,7 +86,6 @@ set (common_sources lua/init.cc lua/fiber.cc lua/trigger.cc - lua/errinj.cc lua/ipc.cc lua/socket.cc lua/session.cc diff --git a/src/box/CMakeLists.txt b/src/box/CMakeLists.txt index 31067cc95a445324da0755bc3282a113b562664c..12177aceb0bec7c7db4db5c5d89535f63b76f282 100644 --- a/src/box/CMakeLists.txt +++ b/src/box/CMakeLists.txt @@ -50,4 +50,5 @@ add_library(box lua/space.cc lua/info.cc lua/stat.cc + lua/error.cc ${bin_sources}) diff --git a/src/box/lua/call.cc b/src/box/lua/call.cc index 3c6929f8ece83f63c7284a7fbed3242a63a24c5c..7fed303683ba76dee760ce2407def2cc189d7487 100644 --- a/src/box/lua/call.cc +++ b/src/box/lua/call.cc @@ -29,6 +29,7 @@ #include "box/lua/call.h" #include "pickle.h" +#include "box/lua/error.h" #include "box/lua/tuple.h" #include "box/lua/index.h" #include "box/lua/space.h" @@ -304,7 +305,7 @@ boxffi_select(struct port *port, uint32_t space_id, uint32_t index_id, box_process(port, &request); return 0; } catch (Exception *e) { - /* will be hanled by box.raise() in Lua */ + /* will be hanled by box.error() in Lua */ return -1; } } @@ -368,27 +369,6 @@ lbox_delete(lua_State *L) return lua_gettop(L) - 3; } -static int -lbox_raise(lua_State *L) -{ - if (lua_gettop(L) == 0) { - /* re-throw saved exceptions (if any) */ - if (cord()->exception == NULL) - return 0; - cord()->exception->raise(); - return 0; - } - - if (lua_gettop(L) < 2) - luaL_error(L, "box.raise(): bad arguments"); - uint32_t code = lua_tointeger(L, 1); - if (code >= tnt_error_codes_enum_MAX) - luaL_error(L, "box.raise(): unknown error code"); - const char *str = lua_tostring(L, 2); - tnt_raise(ClientError, str, code); - return 0; -} - /** * A helper to find a Lua function by name and put it * on top of the stack. @@ -537,7 +517,6 @@ lbox_snapshot(struct lua_State *L) } static const struct luaL_reg boxlib[] = { - {"raise", lbox_raise}, {"snapshot", lbox_snapshot}, {NULL, NULL} }; @@ -560,6 +539,7 @@ box_lua_init(struct lua_State *L) luaL_register_module(L, "box.internal", boxlib_internal); lua_pop(L, 1); + box_lua_error_init(L); box_lua_tuple_init(L); box_lua_index_init(L); box_lua_space_init(L); diff --git a/src/box/lua/error.cc b/src/box/lua/error.cc new file mode 100644 index 0000000000000000000000000000000000000000..00d3baabef31e9ec42db683a600fc6b1e81eb643 --- /dev/null +++ b/src/box/lua/error.cc @@ -0,0 +1,172 @@ +/* + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include "box/lua/error.h" + +extern "C" { +#include <lua.h> +#include <lauxlib.h> +#include <lualib.h> +} /* extern "C" */ + +#include <fiber.h> +#include <errcode.h> +#include <errinj.h> + +#include "lua/utils.h" + +static int +lbox_raise(lua_State *L) +{ + uint32_t code = 0; + const char *reason = NULL; + const char *file = ""; + unsigned line = 0; + lua_Debug info; + + /* lua_type(L, 1) == LUA_TTABLE - box.error table */ + int top = lua_gettop(L); + if (top <= 1) { + /* re-throw saved exceptions (if any) */ + if (cord()->exception == NULL) + return 0; + cord()->exception->raise(); + return 0; + } else if (top >= 2 && lua_type(L, 2) == LUA_TNUMBER) { + code = lua_tointeger(L, 2); + reason = tnt_errcode_desc(code); + if (top > 2) { + /* Call string.format(reason, ...) to format message */ + lua_getglobal(L, "string"); + if (lua_isnil(L, -1)) + goto raise; + lua_getfield(L, -1, "format"); + if (lua_isnil(L, -1)) + goto raise; + lua_pushstring(L, reason); + for (int i = 3; i <= top; i++) + lua_pushvalue(L, i); + lua_call(L, top - 1, 1); + reason = lua_tostring(L, -1); + } + } else if (top == 2 && lua_istable(L, 2)) { + /* A special case that rethrows raw error (used by net.box) */ + lua_getfield(L, 2, "code"); + code = lua_tointeger(L, -1); + lua_pop(L, 1); + lua_getfield(L, 2, "reason"); + reason = lua_tostring(L, -1); + if (reason == NULL) + reason = ""; + lua_pop(L, 1); + } else { + luaL_error(L, "box.error(): bad arguments"); + } + +raise: + if (lua_getstack(L, 1, &info) && lua_getinfo(L, "Sl", &info)) { + if (*info.short_src) { + file = info.short_src; + } else if (*info.source) { + file = info.source; + } else { + file = "eval"; + } + line = info.currentline; + } + + /* see tnt_raise() */ + say_debug("ClientError at %s:%i", file, line); + throw new ClientError(file, line, reason, code); + return 0; +} + +static int +lbox_errinj_set(struct lua_State *L) +{ + char *name = (char*)luaL_checkstring(L, 1); + bool state = lua_toboolean(L, 2); + if (errinj_set_byname(name, state)) { + lua_pushfstring(L, "error: can't find error injection '%s'", name); + return 1; + } + lua_pushstring(L, "ok"); + return 1; +} + +static inline int +lbox_errinj_cb(struct errinj *e, void *cb_ctx) +{ + struct lua_State *L = (struct lua_State*)cb_ctx; + lua_pushstring(L, e->name); + lua_newtable(L); + lua_pushstring(L, "state"); + lua_pushboolean(L, e->state); + lua_settable(L, -3); + lua_settable(L, -3); + return 0; +} + +static int +lbox_errinj_info(struct lua_State *L) +{ + lua_newtable(L); + errinj_foreach(lbox_errinj_cb, L); + return 1; +} + +void +box_lua_error_init(struct lua_State *L) { + static const struct luaL_reg errorlib[] = { + {NULL, NULL} + }; + luaL_register(L, "box.error", errorlib); + for (int i = 0; i < tnt_error_codes_enum_MAX; i++) { + const char *name = tnt_error_codes[i].errstr; + if (strstr(name, "UNUSED") || strstr(name, "RESERVED")) + continue; + assert(strncmp(name, "ER_", 3) == 0); + lua_pushnumber(L, i); + /* cut ER_ prefix from constant */ + lua_setfield(L, -2, name + 3); + } + lua_newtable(L); + lua_pushcfunction(L, lbox_raise); + lua_setfield(L, -2, "__call"); + lua_setmetatable(L, -2); + lua_pop(L, 1); + + static const struct luaL_reg errinjlib[] = { + {"info", lbox_errinj_info}, + {"set", lbox_errinj_set}, + {NULL, NULL} + }; + /* box.error.injection is not set by register_module */ + luaL_register_module(L, "box.error.injection", errinjlib); + lua_pop(L, 1); +} diff --git a/src/lua/errinj.h b/src/box/lua/error.h similarity index 88% rename from src/lua/errinj.h rename to src/box/lua/error.h index dce6b11fa3c6083235a61c1d397966429f2a1769..f0dc5895f9834700a901211f522b3ec62afbd12c 100644 --- a/src/lua/errinj.h +++ b/src/box/lua/error.h @@ -1,6 +1,5 @@ -#ifndef INCLUDES_TARANTOOL_LUA_ERRINJ_H -#define INCLUDES_TARANTOOL_LUA_ERRINJ_H - +#ifndef INCLUDES_TARANTOOL_LUA_ERROR_H +#define INCLUDES_TARANTOOL_LUA_ERROR_H /* * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following @@ -31,6 +30,8 @@ */ struct lua_State; -void tarantool_lua_errinj_init(struct lua_State *L); -#endif /* INCLUDES_TARANTOOL_LUA_ERRINJ_H */ +void +box_lua_error_init(struct lua_State *L); + +#endif /* INCLUDES_TARANTOOL_LUA_ERROR_H */ diff --git a/src/box/lua/index.cc b/src/box/lua/index.cc index 44341362e890f0b77e4540e009ae7191381febc0..0371fd0990de3d0659b61b0a3292cc32d9e467b9 100644 --- a/src/box/lua/index.cc +++ b/src/box/lua/index.cc @@ -53,7 +53,7 @@ boxffi_index_len(uint32_t space_id, uint32_t index_id) try { return check_index(space_id, index_id)->size(); } catch (Exception *) { - return (size_t) -1; /* handled by box.raise() in Lua */ + return (size_t) -1; /* handled by box.error() in Lua */ } } @@ -63,7 +63,7 @@ boxffi_index_random(uint32_t space_id, uint32_t index_id, uint32_t rnd) try { return check_index(space_id, index_id)->random(rnd); } catch (Exception *) { - return (struct tuple *) -1; /* handled by box.raise() in Lua */ + return (struct tuple *) -1; /* handled by box.error() in Lua */ } } @@ -99,7 +99,7 @@ boxffi_index_iterator(uint32_t space_id, uint32_t index_id, int type, } catch (Exception *) { if (it) it->free(it); - /* will be hanled by box.raise() in Lua */ + /* will be hanled by box.error() in Lua */ return NULL; } } diff --git a/src/box/lua/load_cfg.lua b/src/box/lua/load_cfg.lua index 6780aea771bf923c8c0c5fe1e69dd477e5a4d267..4d8c73e3a27a8b10b6d5dff00ca00b4f3f557b02 100644 --- a/src/box/lua/load_cfg.lua +++ b/src/box/lua/load_cfg.lua @@ -70,8 +70,7 @@ local function reload_cfg(oldcfg, newcfg) end for key, val in pairs(newcfg) do if dynamic_cfg[key] == nil then - box.raise(box.error.RELOAD_CFG, - "Can't set option '"..key.."' dynamically"); + box.error(box.error.RELOAD_CFG, key); end if val == "" then val = nil diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index cebfe88ad7f03b2daa3a7ff472dbb2b31545fb0f..ad6f5190f1cdfeab1536d7d1d5736366aea7e7c3 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -69,8 +69,8 @@ local function user_resolve(user) return tuple[1] end -box.begin = function() if ffi.C.boxffi_txn_begin() == -1 then box.raise() end end -box.commit = function() if ffi.C.boxffi_txn_commit() == -1 then box.raise() end end +box.begin = function() if ffi.C.boxffi_txn_begin() == -1 then box.error() end end +box.commit = function() if ffi.C.boxffi_txn_commit() == -1 then box.error() end end box.rollback = ffi.C.boxffi_txn_rollback; box.schema.space = {} @@ -89,8 +89,7 @@ box.schema.space.create = function(name, options) if options.if_not_exists then return box.space[name], "not created" else - box.raise(box.error.SPACE_EXISTS, - "Space '"..name.."' already exists") + box.error(box.error.SPACE_EXISTS, name) end end local id @@ -134,8 +133,7 @@ box.schema.space.drop = function(space_id) end end if _space:delete{space_id} == nil then - box.raise(box.error.NO_SUCH_SPACE, - "Space "..space_id.." does not exist") + box.error(box.error.NO_SUCH_SPACE, '#'..tostring(space_id)) end end box.schema.space.rename = function(space_id, space_name) @@ -195,12 +193,10 @@ box.schema.index.rename = function(space_id, index_id, name) end box.schema.index.alter = function(space_id, index_id, options) if box.space[space_id] == nil then - box.raise(box.error.NO_SUCH_SPACE, - "Space "..space_id.." does not exist") + box.error(box.error.NO_SUCH_SPACE, '#'..tostring(space_id)) end if box.space[space_id].index[index_id] == nil then - box.raise(box.error.NO_SUCH_INDEX, - "Index "..index_id.." not found in space"..space_id) + box.error(box.error.NO_SUCH_INDEX, index_id, box.space[space_id].name) end if options == nil then return @@ -217,7 +213,7 @@ box.schema.index.alter = function(space_id, index_id, options) end if options.id ~= nil then if options.parts ~= nil then - box.raise(box.error.PROC_LUA, + box.error(box.error.PROC_LUA, "Don't know how to update both id and parts") end ops = {} @@ -324,7 +320,7 @@ function box.schema.space.bless(space) index_mt.len = function(index) local ret = builtin.boxffi_index_len(index.space.id, index.id) if ret == -1 then - box.raise() + box.error() end return tonumber(ret) end @@ -335,7 +331,7 @@ function box.schema.space.bless(space) -- min and max index_mt.min = function(index, key) if index.type == 'HASH' then - box.raise(box.error.UNSUPPORTED, 'HASH does not support min()') + box.error(box.error.UNSUPPORTED, 'HASH', 'min()') end local lst = index:select(key, { iterator = 'GE', limit = 1 })[1] if lst ~= nil then @@ -346,7 +342,7 @@ function box.schema.space.bless(space) end index_mt.max = function(index, key) if index.type == 'HASH' then - box.raise(box.error.UNSUPPORTED, 'HASH does not support max()') + box.error(box.error.UNSUPPORTED, 'HASH', 'max()') end local lst = index:select(key, { iterator = 'LE', limit = 1 })[1] if lst ~= nil then @@ -359,7 +355,7 @@ function box.schema.space.bless(space) rnd = rnd or math.random() local tuple = builtin.boxffi_index_random(index.space.id, index.id, rnd) if tuple == ffi.cast('void *', -1) then - box.raise() -- error + box.error() -- error elseif tuple ~= nil then return box.tuple.bless(tuple) else @@ -377,9 +373,7 @@ function box.schema.space.bless(space) elseif box.index[opts.iterator] then itype = box.index[opts.iterator] elseif opts.iterator ~= nil then - box.raise(box.error.ITERATOR_TYPE, - "Unknown iterator type '".. - tostring(opts.iterator).."'") + box.error(box.error.ITERATOR_TYPE, tostring(opts.iterator)) end end @@ -387,7 +381,7 @@ function box.schema.space.bless(space) local cdata = builtin.boxffi_index_iterator(index.space.id, index.id, itype, keybuf); if cdata == nil then - box.raise() + box.error() end return fun.wrap(iterator_gen, keybuf, ffi.gc(cdata, iterator_cdata_gc)) @@ -418,9 +412,7 @@ function box.schema.space.bless(space) local function check_index(space, index_id) if space.index[index_id] == nil then - box.raise(box.error.NO_SUCH_INDEX, - string.format("No index #%d is defined in space %d", index_id, - space.id)) + box.error(box.error.NO_SUCH_INDEX, index_id, space.name) end end @@ -429,15 +421,14 @@ function box.schema.space.bless(space) port.size = 0; if builtin.boxffi_select(ffi.cast(port_t, port), index.space.id, index.id, box.index.EQ, 0, 2, key, key_end) ~=0 then - return box.raise() + return box.error() end if port.size == 0 then return elseif port.size == 1 then return box.tuple.bless(port.ret[0]) else - box.raise(box.error.MORE_THAN_ONE_TUPLE, - "More than one tuple found by get()") + box.error(box.error.MORE_THAN_ONE_TUPLE) end end @@ -469,7 +460,7 @@ function box.schema.space.bless(space) port.size = 0; if builtin.boxffi_select(ffi.cast(port_t, port), index.space.id, index.id, iterator, offset, limit, key, key_end) ~=0 then - return box.raise() + return box.error() end local ret = {} @@ -492,7 +483,7 @@ function box.schema.space.bless(space) end index_mt.alter= function(index, options) if index.id == nil or index.space == nil then - box.raise(box.error.PROC_LUA, "Usage: index:alter{opts}") + box.error(box.error.PROC_LUA, "Usage: index:alter{opts}") end return box.schema.index.alter(index.space.id, index.id, options) end @@ -620,7 +611,7 @@ function box.schema.space.bless(space) space_mt.run_triggers = function(space, yesno) local space = ffi.C.space_by_id(space.id) if space == nil then - box.raise(box.error.NO_SUCH_SPACE, "Space not found") + box.error(box.error.NO_SUCH_SPACE, space.name) end ffi.C.space_run_triggers(space, yesno) end @@ -662,8 +653,7 @@ local function object_resolve(object_type, object_name) if object_type == 'space' then local space = box.space[object_name] if space == nil then - box.raise(box.error.NO_SUCH_SPACE, - "Space '"..object_name.."' does not exist") + box.error(box.error.NO_SUCH_SPACE, object_name) end return space.id end @@ -678,8 +668,7 @@ local function object_resolve(object_type, object_name) if func then return func[1] else - box.raise(box.error.NO_SUCH_FUNCTION, - "Function '"..object_name.."' does not exist") + box.error(box.error.NO_SUCH_FUNCTION, object_name) end end if object_type == 'role' then @@ -693,13 +682,11 @@ local function object_resolve(object_type, object_name) if role then return role[1] else - box.raise(box.error.NO_SUCH_USER, - "Role '"..object_name.."' does not exist") + box.error(box.error.NO_SUCH_USER, object_name) end end - box.raise(box.error.UNKNOWN_SCHEMA_OBJECT, - "Unknown object type '"..object_type.."'") + box.error(box.error.UNKNOWN_SCHEMA_OBJECT, object_type) end box.schema.func = {} @@ -707,8 +694,7 @@ box.schema.func.create = function(name) local _func = box.space[box.schema.FUNC_ID] local func = _func.index['name']:get{name} if func then - box.raise(box.error.FUNCTION_EXISTS, - "Function '"..name.."' already exists") + box.error(box.error.FUNCTION_EXISTS, name) end _func:auto_increment{session.uid(), name} end @@ -748,8 +734,7 @@ end box.schema.user.create = function(name, opts) local uid = user_resolve(name) if uid then - box.raise(box.error.USER_EXISTS, - "User '"..name.."' already exists") + box.error(box.error.USER_EXISTS, name) end if opts == nil then opts = {} @@ -765,8 +750,7 @@ end box.schema.user.drop = function(name) local uid = user_resolve(name) if uid == nil then - box.raise(box.error.NO_SUCH_USER, - "User '"..name.."' does not exist") + box.error(box.error.NO_SUCH_USER, name) end -- recursive delete of user data local _priv = box.space[box.schema.PRIV_ID] @@ -789,8 +773,7 @@ box.schema.user.grant = function(user_name, privilege, object_type, object_name, grantor) local uid = user_resolve(user_name) if uid == nil then - box.raise(box.error.NO_SUCH_USER, - "User '"..user_name.."' does not exist") + box.error(box.error.NO_SUCH_USER, user_name) end privilege = privilege_resolve(privilege) local oid = object_resolve(object_type, object_name) @@ -806,8 +789,7 @@ end box.schema.user.revoke = function(user_name, privilege, object_type, object_name) local uid = user_resolve(user_name) if uid == nil then - box.raise(box.error.NO_SUCH_USER, - "User '"..name.."' does not exist") + box.error(box.error.NO_SUCH_USER, name) end privilege = privilege_resolve(privilege) local oid = object_resolve(object_type, object_name) @@ -830,8 +812,7 @@ box.schema.role = {} box.schema.role.create = function(name) local uid = user_resolve(name) if uid then - box.raise(box.error.USER_EXISTS, - "Role '"..name.."' already exists") + box.error(box.error.USER_EXISTS, name) end local _user = box.space[box.schema.USER_ID] _user:auto_increment{session.uid(), name, 'role'} diff --git a/src/box/schema.h b/src/box/schema.h index c8f71c885ce955066317d484852b528ddb309fd7..69b63f66b9464b5f0b245af079b0cc3b4c20137b 100644 --- a/src/box/schema.h +++ b/src/box/schema.h @@ -29,6 +29,7 @@ * SUCH DAMAGE. */ #include "exception.h" +#include <stdio.h> /* snprintf */ enum schema_id { /** Start of the reserved range of system spaces. */ @@ -81,7 +82,9 @@ space_cache_find(uint32_t id) if (space) return space; - tnt_raise(ClientError, ER_NO_SUCH_SPACE, id); + char name[12]; + snprintf(name, sizeof(name), "#%u", id); + tnt_raise(ClientError, ER_NO_SUCH_SPACE, name); } /** diff --git a/src/box/space.h b/src/box/space.h index 73bf6ce8f1e5846e9200a2697385e305df63d8fb..3111b03c33f94eb64fb4f480a96987c7b56696ba 100644 --- a/src/box/space.h +++ b/src/box/space.h @@ -268,7 +268,7 @@ index_find(struct space *space, uint32_t index_id) Index *index = space_index(space, index_id); if (index == NULL) tnt_raise(LoggedError, ER_NO_SUCH_INDEX, index_id, - space_id(space)); + space->def.name); return index; } diff --git a/src/errcode.h b/src/errcode.h index 4da99c65721600502ff5548cc48bd5042dea407f..d6754b9e197ec0997371b43d9d96ef6478b936ae 100644 --- a/src/errcode.h +++ b/src/errcode.h @@ -59,7 +59,7 @@ enum { TNT_ERRMSG_MAX = 512 }; /* 7 */_(ER_SECONDARY, 2, "Can't modify data upon a request on the secondary port.") \ /* 8 */_(ER_INJECTION, 2, "Error injection '%s'") \ /* 9 */_(ER_CREATE_SPACE, 2, "Failed to create space %u: %s") \ - /* 10 */_(ER_SPACE_EXISTS, 2, "Space %u already exists") \ + /* 10 */_(ER_SPACE_EXISTS, 2, "Space '%s' already exists") \ /* 11 */_(ER_DROP_SPACE, 2, "Can't drop space %u: %s") \ /* 12 */_(ER_ALTER_SPACE, 2, "Can't modify space %u: %s") \ /* 13 */_(ER_INDEX_TYPE, 2, "Unsupported index type supplied for index %u in space %u") \ @@ -84,13 +84,13 @@ enum { TNT_ERRMSG_MAX = 512 }; /* 32 */_(ER_PROC_LUA, 2, "%s") \ /* 33 */_(ER_NO_SUCH_PROC, 2, "Procedure '%.*s' is not defined") \ /* 34 */_(ER_NO_SUCH_TRIGGER, 2, "Trigger is not found") \ - /* 35 */_(ER_NO_SUCH_INDEX, 2, "No index #%u is defined in space %u") \ - /* 36 */_(ER_NO_SUCH_SPACE, 2, "Space %u does not exist") \ + /* 35 */_(ER_NO_SUCH_INDEX, 2, "No index #%u is defined in space '%s'") \ + /* 36 */_(ER_NO_SUCH_SPACE, 2, "Space '%s' does not exist") \ /* 37 */_(ER_NO_SUCH_FIELD, 2, "Field %u was not found in the tuple") \ /* 38 */_(ER_SPACE_FIELD_COUNT, 2, "Tuple field count %u does not match space %u field count %u") \ /* 39 */_(ER_INDEX_FIELD_COUNT, 2, "Tuple field count %u is less than required by a defined index (expected %u)") \ /* 40 */_(ER_WAL_IO, 2, "Failed to write to disk") \ - /* 41 */_(ER_MORE_THAN_ONE_TUPLE, 2, "More than one tuple found") \ + /* 41 */_(ER_MORE_THAN_ONE_TUPLE, 2, "More than one tuple found by get()") \ /* 42 */_(ER_ACCESS_DENIED, 2, "%s access denied for user '%s'") \ /* 43 */_(ER_CREATE_USER, 2, "Failed to create user '%s': %s") \ /* 44 */_(ER_DROP_USER, 2, "Failed to drop user '%s': %s") \ @@ -121,7 +121,7 @@ enum { TNT_ERRMSG_MAX = 512 }; /* 69 */_(ER_MISSING_REQUEST_FIELD, 2, "Missing mandatory field '%s' in request") \ /* 70 */_(ER_IDENTIFIER, 2, "Invalid identifier '%s' (expected letters, digits or an underscore)") \ /* 71 */_(ER_DROP_FUNCTION, 2, "Can't drop function %u: %s") \ - /* 72 */_(ER_ITERATOR_TYPE, 2, "Unknown iterator type %s") \ + /* 72 */_(ER_ITERATOR_TYPE, 2, "Unknown iterator type '%s'") \ /* 73 */_(ER_REPLICA_MAX, 2, "Replica count limit reached: %u") \ /* 74 */_(ER_INVALID_XLOG, 2, "Failed to read xlog: %lld") \ /* 75 */_(ER_INVALID_XLOG_NAME, 2, "Invalid xlog name: expected %lld got %lld") \ @@ -146,7 +146,7 @@ extern struct errcode_record tnt_error_codes[]; static inline const char *tnt_errcode_str(uint32_t errcode) { if (errcode >= tnt_error_codes_enum_MAX) { - /* Unknown error code - can be triggered using box.raise() */ + /* Unknown error code - can be triggered using box.error() */ return "ER_UNKNOWN"; } return tnt_error_codes[errcode].errstr; diff --git a/src/lua/box_net_box.lua b/src/lua/box_net_box.lua index 517fe3fb0739c5fe3220c9f466d0719f06dcfec5..149f25552a21970fa64ea86bde932fef469bd8e2 100644 --- a/src/lua/box_net_box.lua +++ b/src/lua/box_net_box.lua @@ -171,15 +171,11 @@ local proto = { opts = {} end if spaceno == nil or type(spaceno) ~= 'number' then - box.raise(box.error.NO_SUCH_SPACE, - string.format("Space %s does not exist", tostring(spaceno))) + box.error(box.error.NO_SUCH_SPACE, '#'..tostring(spaceno)) end if indexno == nil or type(indexno) ~= 'number' then - box.raise(box.error.NO_SUCH_INDEX, - string.format("No index #%s is defined in space %s", - tostring(spaceno), - tostring(indexno))) + box.error(box.error.NO_SUCH_INDEX, indexno, '#'..tostring(spaceno)) end local body = { @@ -203,8 +199,7 @@ local proto = { if type(opts.iterator) == 'string' then local iterator = box.index[ opts.iterator ] if iterator == nil then - box.raise(box.error.INVALID_MSGPACK, - "Wrong iterator " .. opts.iterator) + box.error(box.error.ITERATOR_TYPE, tostring(opts.iterator)) end body[ITERATOR] = iterator else @@ -266,8 +261,7 @@ local function space_metatable(self) if #res == 1 then return res[1] end - box.raise(box.error.MORE_THAN_ONE_TUPLE, - "More than one tuple found by get()") + box.error(box.error.MORE_THAN_ONE_TUPLE) end } } @@ -291,8 +285,7 @@ local function index_metatable(self) if #res == 1 then return res[1] end - box.raise(box.error.MORE_THAN_ONE_TUPLE, - "More than one tuple found by get()") + box.error(box.error.MORE_THAN_ONE_TUPLE) end, min = function(idx, key) @@ -425,7 +418,7 @@ local remote_methods = { if not cn:wait_connected(timeout) then cn:close() - box.raise(box.error.TIMEOUT, 'Timeout exceeded') + box.error(box.error.TIMEOUT) end return cn end @@ -845,15 +838,14 @@ local remote_methods = { if self.state == 'closed' then if raise then - box.raise(box.error.NO_CONNECTION, - "Connection was closed") + box.error(box.error.NO_CONNECTION) end end if self.timeouts[fid] <= 0 then self.timeouts[fid] = nil if raise then - box.raise(box.error.TIMEOUT, 'Timeout exceeded') + box.error(box.error.TIMEOUT) else return { hdr = { [TYPE] = bit.bor(ERROR_TYPE, box.error.TIMEOUT) }, @@ -893,7 +885,7 @@ local remote_methods = { if response == nil then if raise then - box.raise(box.error.TIMEOUT, 'Timeout exceeded') + box.error(box.error.TIMEOUT) else return { hdr = { [TYPE] = bit.bor(ERROR_TYPE, box.error.TIMEOUT) }, @@ -903,8 +895,10 @@ local remote_methods = { end if raise and response.hdr[TYPE] ~= OK then - local errcode = bit.band(response.hdr[TYPE], ERROR - 1) - box.raise(errcode, response.body[ERROR]) + box.error({ + code = response.hdr[TYPE], + reason = response.body[ERROR] + }) end if response.body[DATA] ~= nil then @@ -971,8 +965,16 @@ remote.self = { end } -setmetatable(remote.self, { __index = box }) +setmetatable(remote.self, { + __index = function(self, key) + if key == 'space' then + -- proxy self.space to box.space + return require('box').space + end + return nil + end +}) return remote diff --git a/src/lua/errinj.cc b/src/lua/errinj.cc deleted file mode 100644 index 7425035d79728ddf7410d259dff9fbbb4e6d7ec5..0000000000000000000000000000000000000000 --- a/src/lua/errinj.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * 1. Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "lua/errinj.h" - -#include <errinj.h> - -extern "C" { -#include <lua.h> -#include <lauxlib.h> -#include <lualib.h> -} /* extern "C" */ - -static int -lbox_errinj_set(struct lua_State *L) -{ - char *name = (char*)luaL_checkstring(L, 1); - bool state = lua_toboolean(L, 2); - if (errinj_set_byname(name, state)) { - lua_pushfstring(L, "error: can't find error injection '%s'", name); - return 1; - } - lua_pushstring(L, "ok"); - return 1; -} - -static inline int -lbox_errinj_cb(struct errinj *e, void *cb_ctx) -{ - struct lua_State *L = (struct lua_State*)cb_ctx; - lua_pushstring(L, e->name); - lua_newtable(L); - lua_pushstring(L, "state"); - lua_pushboolean(L, e->state); - lua_settable(L, -3); - lua_settable(L, -3); - return 0; -} - -static int -lbox_errinj_info(struct lua_State *L) -{ - lua_newtable(L); - errinj_foreach(lbox_errinj_cb, L); - return 1; -} - -static const struct luaL_reg errinjlib[] = { - {"info", lbox_errinj_info}, - {"set", lbox_errinj_set}, - {NULL, NULL} -}; - -/** Initialize box.errinj package. */ -void -tarantool_lua_errinj_init(struct lua_State *L) -{ - luaL_register(L, "errinj", errinjlib); - lua_pop(L, 1); -} diff --git a/src/lua/init.cc b/src/lua/init.cc index fbbfda3bf542fb5bdfc324e19f8ef4b75bc18e9d..7cb7ca0d0234331e951af00f9e3364f7d8ed1606 100644 --- a/src/lua/init.cc +++ b/src/lua/init.cc @@ -48,7 +48,6 @@ extern "C" { #include <scoped_guard.h> #include "coeio.h" #include "lua/fiber.h" -#include "lua/errinj.h" #include "lua/ipc.h" #include "lua/errno.h" #include "lua/socket.h" @@ -176,25 +175,6 @@ lbox_coredump(struct lua_State *L __attribute__((unused))) return 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++) { - const char *name = tnt_error_codes[i].errstr; - if (strstr(name, "UNUSED") || strstr(name, "RESERVED")) - continue; - assert(strncmp(name, "ER_", 3) == 0); - lua_pushnumber(L, i); - /* cut ER_ prefix from constant */ - lua_setfield(L, -2, name + 3); - } - lua_pop(L, 1); -} - /* }}} */ /* @@ -296,7 +276,6 @@ tarantool_lua_init(const char *tarantool_bin, int argc, char **argv) lua_register(L, "tonumber64", lbox_tonumber64); lua_register(L, "coredump", lbox_coredump); - tarantool_lua_errinj_init(L); tarantool_lua_fiber_init(L); tarantool_lua_cjson_init(L); tarantool_lua_yaml_init(L); @@ -305,7 +284,6 @@ tarantool_lua_init(const char *tarantool_bin, int argc, char **argv) tarantool_lua_socket_init(L); tarantool_lua_bsdsocket_init(L); tarantool_lua_session_init(L); - tarantool_lua_error_init(L); tarantool_lua_pickle_init(L); luaopen_msgpack(L); lua_pop(L, 1); diff --git a/test/app/cfg.result b/test/app/cfg.result index 804aeb7327bdb676764a53f975588204543d8dc5..1ce036cf2d52286c3780141fd4461229e6948f2d 100644 --- a/test/app/cfg.result +++ b/test/app/cfg.result @@ -1,3 +1,3 @@ -false [string "-- load_cfg.lua - internal file..."]:100: Please call box.cfg{} first +false [string "-- load_cfg.lua - internal file..."]:99: Please call box.cfg{} first true table -false [string "-- load_cfg.lua - internal file..."]:100: Please call box.cfg{} first +false [string "-- load_cfg.lua - internal file..."]:99: Please call box.cfg{} first diff --git a/test/app/pcall.result b/test/app/pcall.result index e70f316bc71f624ac6e84a1e1646fd9aecb6442d..38429cee4f3dd09d68120c3431823f0cf01a2f86 100644 --- a/test/app/pcall.result +++ b/test/app/pcall.result @@ -4,7 +4,7 @@ pcall inside xpcall: true pcall is ok pcall with Lua error(): false some message -pcall with box.raise(): false some message +pcall with box.error(): false Illegal parameters, some message pcall with no return: 1 pcall with multireturn: true 1 2 3 -------------------------------------------------------------------------------- diff --git a/test/app/pcall.test.lua b/test/app/pcall.test.lua index 248ccbd7b6344cb687f062fa61ebbd10eb63bcfa..91557e3218925e2200b40bb60fbc9bfe052842b5 100755 --- a/test/app/pcall.test.lua +++ b/test/app/pcall.test.lua @@ -26,9 +26,9 @@ local status, msg = pcall(function() error('some message') end) print('pcall with Lua error():', status, msg:match('some message')) local status, msg = pcall(function() - box.raise(box.error.ILLEGAL_PARAMS, 'some message') + box.error(box.error.ILLEGAL_PARAMS, 'some message') end) -print('pcall with box.raise():', status, msg) +print('pcall with box.error():', status, msg) print('pcall with no return:', select('#', pcall(function() end))) print('pcall with multireturn:', pcall(function() return 1, 2, 3 end)) diff --git a/test/box/access.result b/test/box/access.result index 207457a2fab55ee68b3732b7c0b727dab64be8c5..d4fdbc98140a02a4901e96160de4863be7df8d1a 100644 --- a/test/box/access.result +++ b/test/box/access.result @@ -82,7 +82,7 @@ end; ... usermax(); --- -- error: User 'user29' does not exist +- error: User 'user29' is not found ... --# setopt delimiter '' box.schema.user.create('rich') diff --git a/test/box/alter.result b/test/box/alter.result index 1d454079d4b400085b3c122fb1ee105c30f1e6c0..76edd8110395f9d10bcd836728b90823b9c05f24 100644 --- a/test/box/alter.result +++ b/test/box/alter.result @@ -104,23 +104,23 @@ space.index[0] -- space:select{0} --- -- error: 'No index #0 is defined in space 321' +- error: 'No index #0 is defined in space ''hello''' ... space:insert{0, 0} --- -- error: 'No index #0 is defined in space 321' +- error: 'No index #0 is defined in space ''hello''' ... space:replace{0, 0} --- -- error: 'No index #0 is defined in space 321' +- error: 'No index #0 is defined in space ''hello''' ... space:update({0}, {{'+', 1, 1}}) --- -- error: 'No index #0 is defined in space 321' +- error: 'No index #0 is defined in space ''hello''' ... space:delete{0} --- -- error: 'No index #0 is defined in space 321' +- error: 'No index #0 is defined in space ''hello''' ... t = _space:delete{space.id} --- @@ -134,7 +134,7 @@ space_deleted ... space:replace{0} --- -- error: Space 321 does not exist +- error: Space '#321' does not exist ... _index:insert{_space.id, 0, 'primary', 'tree', 1, 1, 0, 'num'} --- diff --git a/test/box/alter_limits.result b/test/box/alter_limits.result index f03a38d38630c715a302a785cab82b37fb0201f8..87d1cc2bbda53d04bea0bfcd3efefa66f9d3d2da 100644 --- a/test/box/alter_limits.result +++ b/test/box/alter_limits.result @@ -66,7 +66,7 @@ s:drop() -- no such space s:drop() --- -- error: Space 512 does not exist +- error: Space '#512' does not exist ... -- no such engine box.schema.create_space('tweedleedee', { engine = 'unknown' }) @@ -135,23 +135,23 @@ s = box.schema.create_space('tweedledum') ... s:insert{0} --- -- error: 'No index #0 is defined in space 512' +- error: 'No index #0 is defined in space ''tweedledum''' ... s:select{} --- -- error: 'No index #0 is defined in space 512' +- error: 'No index #0 is defined in space ''tweedledum''' ... s:delete{0} --- -- error: 'No index #0 is defined in space 512' +- error: 'No index #0 is defined in space ''tweedledum''' ... s:update(0, {{"=", 1, 0}}) --- -- error: 'No index #0 is defined in space 512' +- error: 'No index #0 is defined in space ''tweedledum''' ... s:insert{0} --- -- error: 'No index #0 is defined in space 512' +- error: 'No index #0 is defined in space ''tweedledum''' ... s.index[0] --- @@ -898,7 +898,7 @@ primary.id ... primary:select{} --- -- error: 'No index #0 is defined in space 512' +- error: 'No index #0 is defined in space ''test''' ... s:drop() --- diff --git a/test/box/auth_access.result b/test/box/auth_access.result index 02db9c129ba103ac7419a587fc786dd4de74a421..47f6b8bec95929b8f1a93a0e70d3161217704490 100644 --- a/test/box/auth_access.result +++ b/test/box/auth_access.result @@ -19,7 +19,7 @@ s:drop() ... s:drop() --- -- error: Space 512 does not exist +- error: Space '#512' does not exist ... -- -- Check double create user @@ -131,7 +131,7 @@ box.schema.user.drop('testus') ... box.schema.user.drop('testus') --- -- error: User 'testus' does not exist +- error: User 'testus' is not found ... -- -- Check 'guest' user @@ -288,7 +288,7 @@ box.schema.func.drop('uniuser_func') ... box.schema.user.drop('uniuser_testus') --- -- error: User 'uniuser_testus' does not exist +- error: User 'uniuser_testus' is not found ... session.su('admin') --- @@ -301,7 +301,7 @@ box.schema.user.drop('someuser') ... box.schema.user.drop('uniuser_testus') --- -- error: User 'uniuser_testus' does not exist +- error: User 'uniuser_testus' is not found ... box.schema.user.drop('uniuser') --- diff --git a/test/box/box.net.box.result b/test/box/box.net.box.result index 907414a7e56febfc3b5d488e1f2a8a7bd77e38e8..9f6f528170de25db79b00db6638f29b7d50a8f4b 100644 --- a/test/box/box.net.box.result +++ b/test/box/box.net.box.result @@ -254,7 +254,7 @@ cn:ping() ... cn:call('test_foo') --- -- error: Connection was closed +- error: Connection is not established ... -- -- 2 reconnect cn = remote:new('127.0.0.1', port, { reconnect_after = .1 }) diff --git a/test/box/box.net.box.test.lua b/test/box/box.net.box.test.lua index 4911ce6a9002c41682a08705f0ea53bbdb4967f0..4bae183153b932e5af5aba64167a3a0a0f19783b 100644 --- a/test/box/box.net.box.test.lua +++ b/test/box/box.net.box.test.lua @@ -149,6 +149,9 @@ cn:timeout(.01):call('ret_after', 1) cn = remote:timeout(0.0000000001):new('127.0.0.1', port, { user = 'netbox', password = '123' }) cn = remote:timeout(1):new('127.0.0.1', port, { user = 'netbox', password = '123' }) + + + remote.self:ping() remote.self.space.net_box_test_space:select{234} remote.self:timeout(123).space.net_box_test_space:select{234} diff --git a/test/box/call.result b/test/box/call.result index 9682d126ae08f73d33afabfd9275a7715fcab54f..3e0fa00834b1834c756d40e50428fbcca15c7e94 100644 --- a/test/box/call.result +++ b/test/box/call.result @@ -45,11 +45,11 @@ call f1() errcode: ER_PROC_RET errmsg: msgpack.encode: can not encode Lua type 'function' ... -call dostring('box.raise(33333, "Hey!")') +call dostring('box.error(33333, "Hey!")') --- - error: - errcode: ER_PROC_LUA - errmsg: [string "box.raise(33333, "Hey!")"]:1: box.raise(): unknown error code + errcode: ER_UNKNOWN (565) + errmsg: Unknown error ... # A test case for Bug#103491 diff --git a/test/box/call.test.py b/test/box/call.test.py index 30e9c12d2e6d87f64c0aa47120685540dad931af..cba95b6cf7dde82d65172ab3d44f74723c4b3092 100644 --- a/test/box/call.test.py +++ b/test/box/call.test.py @@ -14,7 +14,7 @@ sql("call f1()") # A test case for https://github.com/tarantool/tarantool/issues/44 # IPROTO required! -sql("call dostring('box.raise(33333, \"Hey!\")')") +sql("call dostring('box.error(33333, \"Hey!\")')") print """ # A test case for Bug#103491 @@ -70,7 +70,7 @@ sql("call f1('jason', 1, 'test', 2, 'stewart')") admin("space = box.schema.create_space('tweedledum', { id = 0 })") admin("space:create_index('primary', { type = 'hash' })") - + admin("function myreplace(...) return space:replace{...} end") admin("function myinsert(...) return space:insert{...} end") sql("insert into t0 values (1, 'test box delete')") diff --git a/test/box/cfg.result b/test/box/cfg.result index 04c0a7f051d4a8d7af2574b17904bb9279c7a069..f063128c00b65ce88c1b9abac8fd29610ab24c6f 100644 --- a/test/box/cfg.result +++ b/test/box/cfg.result @@ -2,7 +2,7 @@ --# push filter 'admin: .*' to 'admin: <uri>' box.cfg.nosuchoption = 1 --- -- error: '[string "-- load_cfg.lua - internal file..."]:127: Attempt to modify a read-only +- error: '[string "-- load_cfg.lua - internal file..."]:126: Attempt to modify a read-only table' ... t = {} for k,v in pairs(box.cfg) do if type(v) ~= 'table' and type(v) ~= 'function' then table.insert(t, k..': '..tostring(v)) end end diff --git a/test/box/errinj.result b/test/box/errinj.result index b12dcf3861ef1132049fb4c0361740b3e3b92460..e525ed83c1d11dab10a269a7d30ab154aca470f6 100644 --- a/test/box/errinj.result +++ b/test/box/errinj.result @@ -1,4 +1,4 @@ -errinj = require('errinj') +errinj = require('box.error.injection') --- ... space = box.schema.create_space('tweedledum') @@ -196,7 +196,7 @@ s_disabled.enabled ... s_disabled:insert{0} --- -- error: 'No index #0 is defined in space 512' +- error: 'No index #0 is defined in space ''disabled''' ... s_withindex:create_index('secondary', { type = 'tree', parts = { 2, 'num'} }) --- @@ -271,7 +271,7 @@ box.space['withdata'] ... s_withdata:create_index('another', { type = 'tree', parts = { 5, 'num' }, unique = false}) --- -- error: Space 514 does not exist +- error: Space '#514' does not exist ... s_withdata.index.another --- diff --git a/test/box/errinj.test.lua b/test/box/errinj.test.lua index 45bebb3f53f9415929048e0466303c325c8ef814..d16edf5c9d85b9de3c613aaef34e611b2fee85c7 100644 --- a/test/box/errinj.test.lua +++ b/test/box/errinj.test.lua @@ -1,4 +1,4 @@ -errinj = require('errinj') +errinj = require('box.error.injection') space = box.schema.create_space('tweedledum') space:create_index('primary', { type = 'hash' }) diff --git a/test/box/errinj_index.result b/test/box/errinj_index.result index a13929773801ed7f204bb5168778b42bcb5c000f..0bce3216dacf3de941595092b597ceb614018a3d 100644 --- a/test/box/errinj_index.result +++ b/test/box/errinj_index.result @@ -1,4 +1,4 @@ -errinj = require('errinj') +errinj = require('box.error.injection') --- ... -- Check a failed realloc in tree index. diff --git a/test/box/errinj_index.test.lua b/test/box/errinj_index.test.lua index cf4baaf4c3af3584082ffae0e21f2e41511edce4..3a339d4aca6007e14c35271211903ab268327824 100644 --- a/test/box/errinj_index.test.lua +++ b/test/box/errinj_index.test.lua @@ -1,4 +1,4 @@ -errinj = require('errinj') +errinj = require('box.error.injection') -- Check a failed realloc in tree index. diff --git a/test/box/misc.result b/test/box/misc.result index 351a4edfc542b17f51772d973662a19466094985..cc87edfc46dc383cfbbe214d84da93021f0b7fbc 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -22,7 +22,6 @@ t - error - index - info - - raise - rollback - schema - slab @@ -35,36 +34,25 @@ t = nil --- ... ---------------- --- # box.raise +-- # box.error ---------------- --# stop server default --# start server default --- during server starting there could be exceptions, --- therefore box.raise() call can throw and can not throw, --- that's why we can't test box.raise() result -1 + 1 ---- -- 2 -... -box.raise(123, 'test') ---- -- error: 'box.raise(): unknown error code' -... -box.raise(0, 'the other test') +box.error({code = 123, reason = 'test'}) --- -- error: the other test +- error: test ... -box.raise(12, 345) +box.error(box.error.ILLEGAL_PARAMS, "bla bla") --- -- error: '345' +- error: Illegal parameters, bla bla ... -box.raise() +box.error() --- -- error: '345' +- error: Illegal parameters, bla bla ... -box.raise() +box.error() --- -- error: '345' +- error: Illegal parameters, bla bla ... space = box.space.tweedledum --- diff --git a/test/box/misc.test.lua b/test/box/misc.test.lua index 94c70cb5b6d830b8290a5bc97c3a348f3ae77090..4a5ea92d6a2b8ceeebbdc13d6ba5a6ab58a0dbd5 100644 --- a/test/box/misc.test.lua +++ b/test/box/misc.test.lua @@ -10,21 +10,15 @@ t t = nil ---------------- --- # box.raise +-- # box.error ---------------- --# stop server default --# start server default --- during server starting there could be exceptions, --- therefore box.raise() call can throw and can not throw, --- that's why we can't test box.raise() result - -1 + 1 -box.raise(123, 'test') -box.raise(0, 'the other test') -box.raise(12, 345) -box.raise() -box.raise() +box.error({code = 123, reason = 'test'}) +box.error(box.error.ILLEGAL_PARAMS, "bla bla") +box.error() +box.error() space = box.space.tweedledum diff --git a/test/box/sql.result b/test/box/sql.result index 764055da360e41705bd97128c0b21b94c28de046..cd40f5349dea5e2321d31a20ee043b4966752c6a 100644 --- a/test/box/sql.result +++ b/test/box/sql.result @@ -168,19 +168,19 @@ select * from t1 where k0 = 0 --- - error: errcode: ER_NO_SUCH_SPACE - errmsg: Space 1 does not exist + errmsg: Space '#1' does not exist ... select * from t65537 where k0 = 0 --- - error: errcode: ER_NO_SUCH_SPACE - errmsg: Space 65537 does not exist + errmsg: Space '#65537' does not exist ... select * from t4294967295 where k0 = 0 --- - error: errcode: ER_NO_SUCH_SPACE - errmsg: Space 4294967295 does not exist + errmsg: Space '#4294967295' does not exist ... box.space[0]:drop() ---