mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-01 14:38:50 +00:00
refactor(lib/lua): safeArgs error messages
This commit is contained in:
1 parent
b8d2e16ed6
commit
57bf223a7d
1 file changed
+8
-4
+8
-4
@@ -35,22 +35,26 @@ local function safeArgs(query, parameters, cb, transaction)
|
||||
if type(query) == 'number' then query = Store[query] end
|
||||
|
||||
if transaction then
|
||||
assert(type(query) == 'table', ('Transaction query expects a table, received %s'):format(query))
|
||||
if type(query) ~= 'table' then
|
||||
error(("First argument expected table, received '%s'"):format(query))
|
||||
end
|
||||
else
|
||||
assert(type(query) == 'string', ('Query expects a string, received %s'):format(query))
|
||||
if type(query) ~= 'string' then
|
||||
error(("First argument expected string, received '%s'"):format(query))
|
||||
end
|
||||
end
|
||||
|
||||
if parameters then
|
||||
local type = type(parameters)
|
||||
if type ~= 'table' and type ~= 'function' then
|
||||
error(('Parameters expected table or function, received %s'):format(parameters))
|
||||
error(("Second argument expected table or function, received '%s'"):format(parameters))
|
||||
end
|
||||
end
|
||||
|
||||
if cb then
|
||||
local type = type(cb)
|
||||
if type ~= 'function' and (type == 'table' and not cb.__cfx_functionReference) then
|
||||
error(('Callback expects a function, received %s'):format(cb))
|
||||
error(("Third argument expected function, received '%s'"):format(cb))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user