[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re[3]: getting call stack in case of a run-time error
- From: Dmitriy Iassenev <iassenev@...>
- Date: Wed, 21 Apr 2004 21:02:00 +0300
Hello Tomas,
Wednesday, April 21, 2004, 8:40:40 PM, you wrote:
T> I'm sorry. I forgot to mention that you to use it inside
T> a "xpcall". For instance, supose you want to call function x
T> with a set of different arguments:
T> function x (s)
T> return '('..s..')'
T> end
T> for _, s in ipairs{ "abc", 23, {} } do
T> local ok, msg_or_str = xpcall (function () return x(s) end, debug.traceback)
T> if ok then
T> print ("Ok!", msg_or_str)
T> else
T> print ("Fail!", msg_or_str)
T> end
T> end
T> The arguments are on the table { "abc", 23, {} }.
T> Ok! (abc)
T> Ok! (23)
T> Fail! test.lua:2: attempt to concatenate local `s' (a table value)
T> stack traceback:
T> test.lua:2: in function `x'
T> (tail call): ?
T> [C]: in function `xpcall'
T> test.lua:6: in main chunk
T> [C]: ?
T> The error message was created by debug.traceback and returned
T> by xpcall as the second return value. `test.lua` is the name of the
T> file where the code was written.
Thank you, Thomas, but is there any way to do the same thing from the
C part of the code? Let's consider the following example.
I created new lua thread. Then I pushed a string to run and called
lua_resume(). btw, it'll be good to include function is_yielded() which
is (L->ci->state & CI_YIELD) into the Lua library functions. So then I
resume thread until it is completed. But if there is an error during
its execution, I'd like to show the call stack. Is it possible without
using hooks?
--
Best regards,
Dmitriy mailto:iassenev@gsc-game.kiev.ua