** Message handler used to run all chunks */
| 175 | ** Message handler used to run all chunks |
| 176 | */ |
| 177 | static int msghandler(lua_State *L) { |
| 178 | const char *msg = lua_tostring(L, 1); |
| 179 | if (msg == nullptr) { /* is error object not a string? */ |
| 180 | if (luaL_callmeta(L, 1, "__tostring") && /* does it have a metamethod */ |
| 181 | lua_type(L, -1) == LUA_TSTRING) /* that produces a string? */ |
| 182 | return 1; /* that is the message */ |
| 183 | else |
| 184 | msg = lua_pushfstring(L, "(error object is a %s value)", |
| 185 | luaL_typename(L, 1)); |
| 186 | } |
| 187 | luaL_traceback(L, L, msg, 1); /* append a standard traceback */ |
| 188 | return 1; /* return the traceback */ |
| 189 | } |
| 190 | |
| 191 | |
| 192 | /* |
nothing calls this directly
no test coverage detected