lua-users home
lua-l archive

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



Have you noticed the error() call's parameter for this?

"error (message [, level])

..
The level argument specifies where the error message points the error. With level 1 (the default), the error position is where the error function was called. Level 2 points the error to
where the function that called error was called; and so on."


Wesley Smith kirjoitti 7.1.2007 kello 23.15:

I've integrated Lua into my project by having some (const char *)s
hard coded into the C source files for assigning and manipulating
metatables of my userdata while the scripts are loaded from disk.
When there's an error and the Lua as gone through one of the hard
coded Lua chunks in my C code, luaL_error reports a line number from
the Lua chunk in my C source.  What I'd like to do instead is have the
error track back from the C function back through the metafunctions in
my C source, and finally back into the loaded from disk Lua script and
report the line number there.  Is this possible?

I basically have this structure

Lua Script -> C source metafunctions -> C function

How can I propagate back up to the Lua Script level from a detected
error in the C function and subsequently report the line number with
luaL_where()?

thanks,
wes