Skip to content
Snippets Groups Projects
Commit 3bfb1cec authored by Nikita Pettik's avatar Nikita Pettik Committed by Vladimir Davydov
Browse files

net.box: fix box.error() usage

box.error() expects first argument to be numeric or table; passing
string to it is wrong. Accidentally in net.box module two places where
string is passed to box.error() as first argument: in :unprepare() and
:connect() methods. Let's fix them and pass error code ER_ILLEGAL_PARAMS.

NO_DOC=<bugfix>
NO_CHANGELOG=<Minor>

(cherry picked from commit a74c549a)
parent c7fa00e2
No related branches found
No related tags found
No related merge requests found
......@@ -355,7 +355,8 @@ local function new_sm(uri, opts)
end
end
if opts.console then
box.error("Netbox text protocol support was dropped, " ..
box.error(box.error.ILLEGAL_PARAMS,
"Netbox text protocol support was dropped, " ..
"please use require('console').connect() instead")
else
setmetatable(remote, remote_mt)
......@@ -817,7 +818,8 @@ end
function remote_methods:unprepare(query, parameters, sql_opts, netbox_opts)
check_remote_arg(self, "unprepare")
if type(query) ~= "number" then
box.error("query id is expected to be numeric")
box.error(box.error.ILLEGAL_PARAMS,
"query id is expected to be numeric")
end
if sql_opts ~= nil then
box.error(box.error.UNSUPPORTED, "unprepare", "options")
......
......@@ -301,3 +301,16 @@ g.after_test('test_schemaless', function()
end
end)
end)
g.test_box_error = function()
t.assert_error_msg_equals(
"Illegal parameters, Netbox text protocol support was dropped, "..
"please use require('console').connect() instead",
net.connect, g.server.net_box_uri, {console = 123})
local c = net.connect(g.server.net_box_uri)
t.assert_error_msg_equals(
"Illegal parameters, query id is expected to be numeric",
c.unprepare, c, "asd")
c:close()
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment