Protected Mode and Error Handling #385
Replies: 2 comments 6 replies
-
Very helpful. As far as I could tell, Lua 5.1 has error handling (or pcall) as well. It might differ from version 5.4 which the link indicates at. |
Beta Was this translation helpful? Give feedback.
-
_Thanks for posting this!!.. _ Confirming pcall(func()) catches the constant lua-induced Ctrlr pukes.
current design pattern I'm using( not sure if the console output has value in staying ) doSomething = function()
if pcall(doSomethingTry) then
console("Success")
else
console("Fail")
end
end
doSomethingTry = function()
-- something smart
end Decided to check here before tabling lua for the time being and just using the poo-brain fields for everything until a brick-wall was found implementing something that needed a more complex handler. Thanks again! |
Beta Was this translation helpful? Give feedback.
-
Here is a very handy link to allow us to make our panels less likely to crash and more importantly less likely to crash the host.
https://www.tutorialspoint.com/lua/lua_error_handling.htm
I think we should use assert and pcall a lot more often in our code. LUA doesn't seem to do everything in protected mode by default, and VST's don't seem to run in protected mode within VST hosts. So an error in our code can crash our host.
pcall allows any LUA function to run in protected mode and allows us to throw custom errors, so as a worst case, it should just stop the function from running without crashing your LUA instance and more importantly the host.
Beta Was this translation helpful? Give feedback.
All reactions