lua-users home
lua-l archive

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

Is it possible to get more structured information from a Lua error callback than a "mangled" string generated by luaL_error()/lua_error()?

As far as I know, it's not.
If not, is there a less dicey way to reduce an error string to a discrete enum than cascading if/else regexes?

Without patching ldo.c, again, not that I know of.
If not, is there code out there (whatever the language) to extract a robust regex mapping table from the Lua VM source code?

That's a fascinating theoretical question.  I suspect the answer is "yes, but it's not worth the trouble."
My debugger is C-only (no extraneous Lua) and I'd really like to avoid patching the Lua VM.

The Lua source is designed to be easy to patch -- particularly where error handling is concerned.  (Grep for the macros LUAI_TRY and LUAI_THROW.)  In my opinion, when it's being embedded in a C++ engine, one of the most useful source changes one can make is to expose Lua's exception types to C++, and vice versa.  Good error handling is a wonderful thing; but of course, it's hard to do without deviating from "clean C".  But if you're willing to compile the sources as C++, the hooks are easy to write.