lua-users home
lua-l archive

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





2013/12/17 Jerome Vuarand <jerome.vuarand@gmail.com>

You need to write:

    lua_getglobal(L, "debug");
    lua_getfield(L, -1, "traceback");
    lua_replace(L, -2);
    lua_getglobal (L, "program01");
    int rv = lua_pcall(L, 0, 0, -2);
    if (rv) { /* ... */; lua_pop(L, 1); /* remove error from the stack */ }
    lua_pop(L, 1); /* remove debug.traceback from the stack */


It works and it is almost good.
I have a message:
TRACEBACK test_traceback.lua:6: attempt to call global 'f0' (a nil value)
stack traceback:
        test_traceback.lua:6: in function 'f1'
        test_traceback.lua:14: in function 'f2'
        test_traceback.lua:19: in function 'f3'
        test_traceback.lua:23: in function <test_traceback.lua:22>

In the last line I would like to have instead <test_traceback.lua:22>, name of the function 'program01'
TRACEBACK test_traceback.lua:6: attempt to call global 'f0' (a nil value)
stack traceback:
        test_traceback.lua:6: in function 'f1'
        test_traceback.lua:14: in function 'f2'
        test_traceback.lua:19: in function 'f3'
        test_traceback.lua:23: in function 'program01'

How to achieve this?

--
Karol Drożak