1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-16 18:01:40 +00:00

Use a Lua error handler that calls tostring (#11913)

This commit is contained in:
Jude Melton-Houghton 2022-12-15 07:37:49 -05:00 committed by GitHub
parent 1f3b5e553b
commit 0fc97a1483
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 45 additions and 9 deletions

View file

@ -9956,3 +9956,17 @@ Bit Library
Functions: bit.tobit, bit.tohex, bit.bnot, bit.band, bit.bor, bit.bxor, bit.lshift, bit.rshift, bit.arshift, bit.rol, bit.ror, bit.bswap
See http://bitop.luajit.org/ for advanced information.
Error Handling
--------------
When an error occurs that is not caught, Minetest calls the function
`minetest.error_handler` with the error object as its first argument. The second
argument is the stack level where the error occurred. The return value is the
error string that should be shown. By default this is a backtrace from
`debug.traceback`. If the error object is not a string, it is first converted
with `tostring` before being displayed. This means that you can use tables as
error objects so long as you give them `__tostring` metamethods.
You can override `minetest.error_handler`. You should call the previous handler
with the correct stack level in your implementation.