feat(plugins): add debug.traceback (#6652)

Reviewed-by: Mm2PL <mm2pl+gh@kotmisia.pl>
This commit is contained in:
nerix
2025-12-28 13:03:43 +01:00
committed by GitHub
parent a9ab584cbb
commit e2ba7dff03
7 changed files with 178 additions and 22 deletions
+25
View File
@@ -850,6 +850,31 @@ and [`file:write()`](https://www.lua.org/manual/5.4/manual.html#pdf-file:write).
See [official documentation](https://www.lua.org/manual/5.4/manual.html#pdf-io.write)
### Debug API
To aid debugging, Chatterino provides Lua's `debug.traceback` function.
Other functions from the `debug` library are not exposed.
#### `traceback([thread,] [message [, level]])`
Returns a stack trace of `thread` or the current thread with an optional `message` prepended.
`level` can be used to skip some frames. By default, it's 1 (skipping the current function).
This can be used as a message handler in `xpcall`:
```lua
local function main()
c2.ThisDoesNotExistAndWillError()
end
local ok, result = xpcall(main, debug.traceback)
if not ok then
print(result)
end
```
See [official documentation](https://www.lua.org/manual/5.4/manual.html#pdf-debug.traceback)
### Changed globals
#### `load(chunk [, chunkname [, mode [, env]]])`