lua-users home
lua-l archive

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


David Jeske wrote:

> 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)

May I'm too dumb, but please explain.
AFAIK Lua 4.0 doesn't have try/except statements.

>  
> > 
> > 	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

-- 
Best regards, Maxim F. Ischenko.