Originally Posted by Fizzlemizz
or are you saying you want to test if RunScript(strLine) is going to run without error before running RunScript(strLine)?
|
Yes
If I write
RunScript("mmmkkhgrttt") I will have a lua error, and I would like to trap this error.
In fact, I'm now able to do this with something like:
Lua Code:
local func, errorMessage = loadstring(strLine)
if (not func) then
isError = true
else
local success, errorMessage = pcall(func)
if (not success) then
isError = true
end
end
The tricky part is to catch errors when a macro is passed to the function
.executeCmd() and processed with:
Lua Code:
if (isMacroBoolean)) then
--------------------------- macro ("/" needed)
if (string.sub(strLine, 1, 1) ~= "/") then strLine = "/"..strLine end
DEFAULT_CHAT_FRAME.editBox:SetText(strLine)
ChatEdit_SendText(DEFAULT_CHAT_FRAME.editBox, 0)
else
...
end
In case of macro passed as strLine, I don't know how to test/try strLine.