[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Exceptions from lua_getfield with __index metamethod
- From: Bryan McGinty <bmcginty@...>
- Date: Thu, 27 Oct 2011 15:50:34 -0700
Hi,
I am writing Lua library code in C. I am attempting to
determine if a global object exists, and if it does has
a particular key.
I first determine if the global object exists using:
lua_getglobal(ls, module);
if (lua_isnil(ls, -1) == 0) {
If the object exists and a key has been specified I then
attempt to determine if the key exists using:
lua_getfield(ls, -1, key);
With this call the object's __index metamethod is called.
If the __index metamethod returns an argument error my
code terminates.
Is there a better way to be doing this operation? If not,
how can I catch the exception?
Regards,
Bryan