[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] patch-lua-5.1.4-3
- From: David Manura <dm.lua@...>
- Date: Mon, 21 Mar 2011 23:47:19 -0400
On Fri, Mar 18, 2011 at 7:42 PM, Daurnimator <quae@daurnimator.com> wrote:
> pxpcall = function(func,errfunc,...) return xpcall( func,function(e)
> pcall(errfunc,e) return true end ) end
The "try" function implemented in Lua Gems Chapter 13 brings the
exception handler outside of the pcall, like this:
function try(f, catch_f)
local status, exception = pcall(f)
if not status then catch_f(exception) end
end -- warning doesn't mix with coroutines in 5.1 (maybe ok in 5.2 though)
Isn't that enough? Admittedly, this introduces quirks in the
tracebacks, which I've described previously [1].
[1] http://lua-users.org/lists/lua-l/2010-08/msg00481.html