StackTracePlus
StackTracePlus copied to clipboard
STP.stacktrace not strictly compatible to debug.traceback
trafficstars
STP.stacktrace is not strictly compatible to debug.traceback: It returns two values, instead of one. This creates problems in conjunction with varargs functions and those created through the Lua C API (which will happily consume the additional argument, creating an unexpected stack layout).
Is this something you want to fix?
--- a/src/StackTracePlus.lua
+++ b/src/StackTracePlus.lua
@@ -391,7 +392,7 @@ Stack Traceback
info = dumper.getinfo(level, "nSlf")
end
- return dumper:concat_lines(), original_error
+ return dumper:concat_lines()
end
--
I'm not sure. Can't you just wrap it in a function to adjust the number of return values? Like,
debug.traceback = function(...) return (STP.stacktrace(...)) end
As a compromise, provide STP.traceback (with name matching debug.traceback) that does exactly that?
Are there any cases where debug.traceback returns 0 or 2 values?