Hi.
I have some code written in Lua:
local function f1 ()
f0 () -- error
end
local function f2 ()
f1 ()
end
local function f3 ()
f2 ()
end
function program01 ()
f3 ()
end
And I have call function "program01" from program written in C:
...
lua_getglobal (L, "program01");
int rv = lua_pcall (L, 0, 0, 0);
if (rv) {
printf ("ERR %s\n", lua_tostring (L, -1));
}
...
How can I trace back execution of this code?
Above code prints only:
ERR .\test_traceback.lua:2: attempt to call global 'f0' (a nil value)
There is debug.traceback () function, but I don't know how to use it.
I would like to get something like that (wxLuaEditor):
Error: Lua: Error while running chunk
[string "test_traceback.lua"]:2: attempt to call global 'f0' (a nil value)
stack traceback:
[string "test_traceback.lua"]:2: in function 'f1'
[string "test_traceback.lua"]:6: in function 'f2'
[string "test_traceback.lua"]:10: in function 'f3'
[string "test_traceback.lua"]:14: in function 'program01'
[string "test_traceback.lua"]:17: in main chunk
Please give me an example.
--
Karol Drożak