[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] patch-lua-5.1.4-3
- From: Daurnimator <quae@...>
- Date: Tue, 22 Mar 2011 16:35:21 +1100
On 22 March 2011 14:47, David Manura <dm.lua@math2.org> wrote:
> 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
>
>
A catch function should be ran in the frame of the error.
Also, you only have to do it that way because of the aforementioned bug.