lua-users home
lua-l archive

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


At 09:10 AM 4/17/2002 -0400, you wrote:
> - error handling: we will probably change functions related to error
> handling (dostring/dofile, call, etc.). We will have a proposal soon.

Any thoughts of some form of exception system for this?

Peter,
I recently had a mild siezure over just this issue ("You mean 'lua_pushnumber' could cause my application to exit??"). I have no idea what solution the powers-that-be are working on right now, but I slapped together a little shim that basically allowed me to explicitly set the function that was called instead of exit(EXIT_FAILURE) in the luaD_breakrun section.

After running some tests, I determined that I could actually throw an exception from C++ code compiled seperately through the C symbols, up to my actual C++ application. Now, granted, this leaves the lua stack in a fairly sticky situation, but it gives me the opportunity at the application level to TWEP the interpreter and continue functioning - as it were - with whatever can be salvaged.

Now for the caveats. Things I don't know: memory leaks and portability. I don't know for certain (haven't spent the time to) that the stack's really being unwound properly. I don't know that all the memory applicable will be cleaned up properly when it exits, and I don't know that it will do the same thing on all compilers. I tested my basic "throw an exception through C code" on GCC and VC++6.0, and the exception was caught with no compiler warnings. Other then that, you're on your own :)

Maybe this will get some ideas flowing.
-G