From 0fc97a1483961e0bc617ca67a348dcb2cbeb6bc0 Mon Sep 17 00:00:00 2001 From: Jude Melton-Houghton Date: Thu, 15 Dec 2022 07:37:49 -0500 Subject: Use a Lua error handler that calls tostring (#11913) --- doc/lua_api.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'doc') 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. -- cgit v1.2.3