From 57bf223a7dca6309314303131b0bd7d6869d28e6 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Mon, 18 Apr 2022 22:52:31 +1000 Subject: [PATCH] refactor(lib/lua): safeArgs error messages --- lib/MySQL.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/MySQL.lua b/lib/MySQL.lua index 6b578e5..42bab2a 100644 --- a/lib/MySQL.lua +++ b/lib/MySQL.lua @@ -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