Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

Commit 57bf223

Browse files
committed
refactor(lib/lua): safeArgs error messages
1 parent b8d2e16 commit 57bf223

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/MySQL.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,26 @@ local function safeArgs(query, parameters, cb, transaction)
3535
if type(query) == 'number' then query = Store[query] end
3636

3737
if transaction then
38-
assert(type(query) == 'table', ('Transaction query expects a table, received %s'):format(query))
38+
if type(query) ~= 'table' then
39+
error(("First argument expected table, received '%s'"):format(query))
40+
end
3941
else
40-
assert(type(query) == 'string', ('Query expects a string, received %s'):format(query))
42+
if type(query) ~= 'string' then
43+
error(("First argument expected string, received '%s'"):format(query))
44+
end
4145
end
4246

4347
if parameters then
4448
local type = type(parameters)
4549
if type ~= 'table' and type ~= 'function' then
46-
error(('Parameters expected table or function, received %s'):format(parameters))
50+
error(("Second argument expected table or function, received '%s'"):format(parameters))
4751
end
4852
end
4953

5054
if cb then
5155
local type = type(cb)
5256
if type ~= 'function' and (type == 'table' and not cb.__cfx_functionReference) then
53-
error(('Callback expects a function, received %s'):format(cb))
57+
error(("Third argument expected function, received '%s'"):format(cb))
5458
end
5559
end
5660

0 commit comments

Comments
 (0)