[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: how to get stacktrace
- From: David Jeske <jeske@...>
- Date: Fri, 22 Jun 2001 10:18:47 -0700
On Fri, Jun 22, 2001 at 04:07:04PM +0300, Max Ischenko wrote:
> I use call() to safely run a Lua function.
> If an error occurs during the call, I want to dump stacktrace and
> continue.
>
> Currently I'm using the following code.
> Would anyone mind to help me improve it?
Interesting how that's really close to a try/except block... (hint,
hint)
>
> local handler = function(errstr)
> local t = getinfo(2) or getinfo(3)
> local s = format("Lua error %s at %s%s",
> errstr, t.currentline or '?', t.source or '?')
> mark_failed(%test, s)
> end
> local code, msg = call(dispatch_command,
> {cmd}, 'x', handler)
--
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net