lua-users home
lua-l archive

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


Hi,

I read the text at http://lua-users.org/wiki/FinalizedExceptions and I
found it very useful ...

The main problem from my point of view is that when you transform
errors into messages (strings) and back into exceptions, you
lose the stack traceback.
So I created a module that instead of transforming transforming
errors into strings, they are transformed into exceptions objects, that
contains the stack traceback. (it uses xpcall)

But, if the exception is not catched, the lua interpreter is not able
to transform the table to a string (the metamethod __tostring is
defined) so the traceback is not displayed. So I replaced the function
debug.traceback by a function that do exactly the same but transform
the error object to a string if it is not.

I would suggest that in future lua releases, the debug.traceback
function should be able to transform any object to a string to display
it.

Here is my module :
http://bzr.mildred632.free.fr/Projects/lua/mymodules-5.1/exception.lua

Mildred

-- 
Mildred       <xmpp:mildred@jabber.fr> <http://mildred632.free.fr/>
Clef GPG :    <hkp://pgp.mit.edu> ou <http://mildred632.free.fr/gpg_key>
Fingerprint : 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]