Open SolraBizna opened 1 year ago
I am naturally in full support of this idea, though I feel like the most sensible way to enable it is to simply have a Lua command that enables it, e.g.,
Game.lua_stack_traces = true
since, almost tautologically, a person that cares about debugging Lua either already writes Lua scripts themselves or will at least be communicating with such a person. If this is deemed insufficient for all possibilities, perhaps an additional command-line argument to enable this for all Lua scripts until the game quits would also make sense.
For simple scripts, line numbers are all that are needed (and a stacktrace would be noise). For complex scripts, stacktraces are sometimes necessary.
The Lua REPL performs all calls into Lua using this wrapper:
If we replace all calls in Aleph One Lua to
lua_pcall
with calls to a utility like that one, we will get stacktraces on all Lua errors. To reduce friction in the (common) case where stacktraces are unhelpful, the insertion of the traceback handler could be gated behind a preference checkbox, defaulting unchecked. (A command line argument would be a tougher sell, and requiring a special debug build is a can of worms we wouldn't want to open in my opinion.)For extra ergonomics, I would make it so that only the first line of a Lua error is displayed on the screen, thus excluding the stacktrace from the inevitable error spam. The full stacktrace would still be written to the standard output. This could be gated by an additional preference or command line option if someone really wants to be able to spam tracebacks.