• Error Handling
    4 replies, posted
Is there a way of handling lua errors, so that I could tell my script to try and fix the issue? Like try...catch in other languages.
There is no try...catch statement in Lua, but consider using gm_luaerror for debugging only: [URL]http://www.facepunch.com/showthread.php?t=859872[/URL]
Damn, alright then.
Take a gander at xpcall and pcall in the documentation on lua.org. They sort of offer trapping.
[lua]local ok, err = pcall(function() -- try equivalent -- do whatever here end) if not ok then -- catch equivalent ErrorNoHalt(err) end[/lua]
Sorry, you need to Log In to post a reply to this thread.