[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Error handling
- From: Mildred <ml.mildred593@...>
- Date: Wed, 10 May 2006 18:56:53 +0200
On Wed, 10 May 2006 09:51:14 +0100 Robert Hibberdine wrote:
> Hi all,
>
> I am writing my first large lua script to run on an embedded system
> and need to handle errors in my own way. I have just discovered
> 'pcall'...
>
> My question is:
> How do I print the function name and line number where the error
> occurred in my own error handler?
If you are interested, I made a exception module for lua 5.1
To use it :
require("exception").install()
then you can use :
raise(exception_id, message)
try(function()
-- some code that may raise exceptions
end, function(e)
if e.error == exception_id then
-- do something
return true
end
return false -- the exception continues
end
It's here:
http://bzr.mildred632.free.fr/viewsource/Projects/lua/mymodules-5.1/exception.lua?action=view
or
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]
--
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]