MCPcopy Create free account
hub / github.com/crownengine/crown / msghandler

Function msghandler

src/lua/lua_environment.cpp:108–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108static int msghandler(lua_State *L)
109{
110 const char *msg = lua_tostring(L, 1);
111 if (msg == NULL) { /* is error object not a string? */
112 if (luaL_callmeta(L, 1, "__tostring") && /* does it have a metamethod */
113 lua_type(L, -1) == LUA_TSTRING) /* that produces a string? */
114 return 1; /* that is the message */
115 else
116 msg = lua_pushfstring(L, "(error object is a %s value)",
117 luaL_typename(L, 1));
118 }
119#if CROWN_USE_LUAJIT
120 luaL_traceback(L, L, msg, 1); /* append a standard traceback */
121#else
122 lua_pushstring(L, "No traceback");
123#endif
124 return 1; /* return the traceback */
125}
126
127/*
128** Prints (calling the Lua 'print' function) any values on the stack

Callers

nothing calls this directly

Calls 5

luaL_tracebackFunction · 0.85
luaL_callmetaFunction · 0.50
lua_typeFunction · 0.50
lua_pushfstringFunction · 0.50
lua_pushstringFunction · 0.50

Tested by

no test coverage detected