[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: on-error debug hook (was: block-scope finalization)
- From: Paul K <paul@...>
- Date: Mon, 16 Nov 2015 18:29:10 +0000
>>> [...] It used to be the
>>> case that debug.traceback was triggered by Lua before the error was
>>> thrown, which allowed for some access to Lua state, but it's no longer
>>> the case with Lua 5.2+.
>> I don't think that changed in Lua 5.2.
> The default Lua interpreter in Lua 5.1 calls `debug.traceback` in the
> message handler, while Lua 5.2/3 use `luaL_traceback` instead.
> `debug.traceback` is easier to monkey-patch ...
Exactly; the following script prints "traceback
...\traceback.lua:2: fails here 2" in Lua 5.1, but throws a
"normal" error in Lua 5.2+
debug.traceback = function(...) print("traceback", ...) end
error("fails here")
The user could also modify the error by returning appropriate result
from debug.traceback.
Paul.