lua-users home
lua-l archive

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



Thank you for that.
Does it work with Lua 5.0? (I use v5.0 because I am using CGILua on my system) At present I am not competent enough in Lua to eitther understand what you've done or back port it to v5.0 if necessary :-)).

Thanks
Bob

Mildred wrote:

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