[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Error Reporting
- From: "John Dunn" <John_Dunn@...>
- Date: Fri, 24 Jul 2009 16:05:08 -0700
I have 2 questions about error reporting back to the user.
The first is pretty simple - are there any examples as to how to use the
optional errorfunc argument to lua_pcall? I'd like to remove some of the
error string but I can't find any examples on how to accomplish that
with a custom errorfunc.
The second question is a little more complicated. I load a user defined
script, in which the user can assign callback functions to objects.
button:AddEventHandler(function() ... end)
but since I wanted a more 'Property' like interface for my users, I
assigned a __newindex() to my metatable
local mt, methods = ...
function mt:__newindex(k, v)
if k == 'EventHandler' then
self: AddEventHandler (v) -- this is
line 47 in my initialization script
so my users can use the following syntax
button.EventHandler = function() ... end
That all works perfectly fine, except if AddEventHandler raises an
error. In that case the line number reported is the line number of the
mt:__newindex() ( which I instantiate behind the scenes and is always
47! ), not the line number in the user script. I'd like to report the
error where the user called .EventHandler, not the internal __newindex
call - any idea how I might go about going that?