[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: How do I check for errors returned from a C function?
- From: "Erik Cassel" <erik@...>
- Date: Fri, 30 Dec 2005 10:11:35 -0800
I suppose people have discussed the merits of adding try/catch/finally
semantics to Lua...
-Erik
_____
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] 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!");
end;
Or, use lua_error in your C function and call SendText in a protected
environment:
local success, error_msg = pcall (Entity:SendText, "Hello!");
if not success then
print ("SendText failed: ", error_msg);
end;
<<attachment: winmail.dat>>