Skip to content

Commit

Permalink
updated error Messages for lua commands
Browse files Browse the repository at this point in the history
  • Loading branch information
daddel80 committed Dec 15, 2024
1 parent 8ec447b commit 84012bb
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/MultiReplacePanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4428,12 +4428,12 @@ bool MultiReplace::resolveLuaSyntax(std::string& inputString, const LuaVariables
"function cond(cond, trueVal, falseVal)\n"
" local res = {result = '', skip = false} -- Initialize result table with defaults\n"
" if cond == nil then -- Check if cond is nil\n"
" error('cond cannot be nil')\n"
" error('cond: condition cannot be nil')\n"
" return res\n"
" end\n"

" if cond and trueVal == nil then -- Check if trueVal is nil\n"
" error('trueVal cannot be nil')\n"
" error('cond: trueVal cannot be nil')\n"
" return res\n"
" end\n"

Expand Down Expand Up @@ -4476,15 +4476,15 @@ bool MultiReplace::resolveLuaSyntax(std::string& inputString, const LuaVariables
"function set(strOrCalc)\n"
" local res = {result = '', skip = false} -- Initialize result table with defaults\n"
" if strOrCalc == nil then\n"
" error('cannot be nil')\n"
" error('set: cannot be nil')\n"
" return\n"
" end\n"
" if type(strOrCalc) == 'string' then\n"
" res.result = strOrCalc -- Setting res.result\n"
" elseif type(strOrCalc) == 'number' then\n"
" res.result = tostring(strOrCalc) -- Convert number to string and set to res.result\n"
" else\n"
" error('Expected string or number')\n"
" error('set: Expected string or number')\n"
" return\n"
" end\n"
" resultTable = res\n"
Expand All @@ -4495,24 +4495,24 @@ bool MultiReplace::resolveLuaSyntax(std::string& inputString, const LuaVariables
luaL_dostring(L,
"function fmtN(num, maxDecimals, fixedDecimals)\n"
" if num == nil then\n"
" error('num cannot be nil')\n"
" error('fmtN: num cannot be nil')\n"
" return\n"
" elseif type(num) ~= 'number' then\n"
" error('Invalid type for num. Expected a number')\n"
" error('fmtN: Invalid type for num. Expected a number')\n"
" return\n"
" end\n"
" if maxDecimals == nil then\n"
" error('maxDecimals cannot be nil')\n"
" error('fmtN: maxDecimals cannot be nil')\n"
" return\n"
" elseif type(maxDecimals) ~= 'number' then\n"
" error('Invalid type for maxDecimals. Expected a number')\n"
" error('fmtN: Invalid type for maxDecimals. Expected a number')\n"
" return\n"
" end\n"
" if fixedDecimals == nil then\n"
" error('fixedDecimals cannot be nil')\n"
" error('fmtN: fixedDecimals cannot be nil')\n"
" return\n"
" elseif type(fixedDecimals) ~= 'boolean' then\n"
" error('Invalid type for fixedDecimals. Expected a boolean')\n"
" error('fmtN: Invalid type for fixedDecimals. Expected a boolean')\n"
" return\n"
" end\n"
" local multiplier = 10 ^ maxDecimals\n"
Expand All @@ -4538,13 +4538,13 @@ bool MultiReplace::resolveLuaSyntax(std::string& inputString, const LuaVariables
" -- Set the global variable only if it does not already exist\n"
" if _G[name] == nil then\n"
" if type(name) ~= 'string' then\n"
" error('Variable name must be a string')\n"
" error('init: Variable name must be a string')\n"
" end\n"
" if not string.match(name, '^[A-Za-z_][A-Za-z0-9_]*$') then\n"
" error('Invalid variable name')\n"
" error('init: Invalid variable name')\n"
" end\n"
" if value == nil then\n"
" error('Value missing in Init')\n"
" error('init: Value missing')\n"
" end\n"
" -- Check if the value is a string and REGEX is true, then preprocess backslashes\n"
" if type(value) == 'string' and REGEX then\n"
Expand Down

0 comments on commit 84012bb

Please sign in to comment.