lua-users home
lua-l archive

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


>From: Ken Rawlings <krawling@bluemarble.net>
>
>   What i'm thinking of is more along the lines of something like Java/C++
>   exception handling:
>
>   try 
>     -- do something   
>   catch
>     -- if an error occurred
>   finally
>     -- always done
>   end

If "do something" can be put into a function, then the code above can be written

	if call(do_something,args,"x") then
		-- catch error
	end
	-- always done

"call" also accepts a function to serve as temporary error handler.
See http://www.tecgraf.puc-rio.br/lua/manual/manual.html#call

--lhf