lua-users home
lua-l archive

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


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?


	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)


-- 
The best writing is rewriting. 
     -- E. B. White