aboutsummaryrefslogtreecommitdiff
path: root/doc/lua_api.txt
diff options
context:
space:
mode:
authorJude Melton-Houghton <jwmhjwmh@gmail.com>2022-12-15 07:37:49 -0500
committerGitHub <noreply@github.com>2022-12-15 07:37:49 -0500
commit0fc97a1483961e0bc617ca67a348dcb2cbeb6bc0 (patch)
treef18593c33d9da74cc49525ab7badab5f55836ef8 /doc/lua_api.txt
parent1f3b5e553bb581deddf468d62954ff238ebb1ac8 (diff)
downloadminetest-0fc97a1483961e0bc617ca67a348dcb2cbeb6bc0.tar.xz
Use a Lua error handler that calls tostring (#11913)
Diffstat (limited to 'doc/lua_api.txt')
-rw-r--r--doc/lua_api.txt14
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index e017df880..ba6ff75f3 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -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.