lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I suppose people have discussed the merits of adding try/catch/finally
semantics to Lua...






[] On Behalf Of Dolan, Ryanne
Thomas (UMR-Student)
Sent: Friday, December 30, 2005 8:06 AM
To: Lua list
Subject: RE: How do I check for errors returned from a C function?


two ways i can think of:


Just return a boolean from your C function, and have your Lua script check
this value against true:


if not Entity:SendText ("Hello!") then

    print ("SendText failed!");



Or, use lua_error in your C function and call SendText in a protected


local success, error_msg = pcall (Entity:SendText, "Hello!");


if not success then

    print ("SendText failed:  ", error_msg);




<<attachment: winmail.dat>>