lua-users home
lua-l archive

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

>From what I can tell, it's exactly what you're looking for.  lua_pcall
allows you to register an error function that gets triggered upon
error.  If it's a C function, simply push it onto the stack to make it
available to Lua.

On Tue, Nov 4, 2008 at 1:09 PM, Thomas Daldier <> wrote:
> Thanks for the reply, but I'm not sure this is exactly what I'm looking for:
>> one way to print errors, but avoid the abortion is to use Lua's error ()
>> function together with pcall (). pcall () catches the error and returns
>> the
>> message.
>> Maybe the assert() function could also be helpful to you.
> These functions are all called from Lua, I need something that Lua will call
> whenever it comes across an error.
>> Further I found this presentation from John Belmonte about exception
>> patterns in
>> Lua:
> Thanks for the link to the presentation, it had a nice list of methods. :)
> Is there some sort of function That I could register in Lua or as a hook to
> print out every single error it comes across to the console?
> My application works like this:
> 1. It gets the file name from the start-up arguments. If one isn't listed,
> it uses a default file name.
> 2. It registers all my functions/tables to to the lua state. (HGE, EveR [ my
> C++ game engine that uses Box2D physics. ], and a few other things)
> 3. It runs the specified file.
> 4. It quits after the file is through running. (It doesn't have anything
> better to do.)
> Thanks,
> --Sgt. Sparky
> :) :) :)
> ________________________________
> See how Windows Mobile brings your life together—at home, work, or on the
> go. See Now