lua-users home
lua-l archive

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



On May 10, 2006, at 10:51, Robert Hibberdine wrote:

How do I print the function name and line number where the error occurred in my own error handler?

In general, you can always discover such information using debug.getinfo():

        local someInfo = debug.getinfo( 3, "Sn" )
        local aClass = someInfo.source
        local aMethod = someInfo.name

http://www.lua.org/pil/23.1.html
http://www.lua.org/manual/5.1/manual.html#pdf-debug.getinfo

There is also a handy debug.traceback to use in conjunction with xpcall:

http://www.lua.org/manual/5.1/manual.html#pdf-debug.traceback

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/