lua-users home
lua-l archive

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


While working on my pure Lua persistence library I found that I need a way to get the current error function, that is, the one passed to the last lua_pcall. I need to add additional information to error message and then call the standard error function to turn it into a full error info. In my case additional information is the object for which persistence failed.

So, it should look somewhat like this:
local oldf = debug.geterrfunc()
local function myerrf(s)
    s = tostring(s).." some additional info"
    return not oldf and s or oldf(s)
end
xpcall(some_function, myerrf)

I think this "geterrfunc" should be a part of standard debug library and also part of C API. I don't like the name "geterrfunc", but I couldn't come up with any good name yet.

--
Best regards,
Sergey Rozhenko                 mailto:sergroj@mail.ru