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