Make lua tracebacks a little better
This commit is contained in:
@@ -50,19 +50,18 @@ int traceback_coroutine(lua_State *L) {
|
||||
if ((ar.currentline > 0) || (*ar.namewhat != 0) || (*ar.what != 'C')) {
|
||||
any = true;
|
||||
lua_pushliteral(L, "\n\t");
|
||||
lua_pushfstring(L, "%s:", ar.short_src);
|
||||
if (ar.currentline > 0)
|
||||
lua_pushfstring(L, "%d:", ar.currentline);
|
||||
lua_pushfstring(L, "%s", ar.short_src);
|
||||
if (ar.currentline > 0 && strcmp(ar.short_src, "<console>"))
|
||||
lua_pushfstring(L, " line %d", ar.currentline);
|
||||
if (*ar.namewhat != '\0') /* is there a name? */
|
||||
lua_pushfstring(L, " in function " LUA_QS, ar.name);
|
||||
else {
|
||||
if (*ar.what == 'm') /* main? */
|
||||
lua_pushfstring(L, " in main chunk");
|
||||
lua_pushfstring(L, " in top-level expression ");
|
||||
else if (*ar.what == 'C' || *ar.what == 't')
|
||||
lua_pushliteral(L, " ?"); /* C function or tail call */
|
||||
lua_pushliteral(L, " in unknown C function");
|
||||
else
|
||||
lua_pushfstring(L, " in function <%s:%d>",
|
||||
ar.short_src, ar.linedefined);
|
||||
lua_pushfstring(L, " in function on line %d", ar.linedefined);
|
||||
}
|
||||
if (1 + lua_gettop(L) - top > 5) {
|
||||
lua_concat(L, 1 + lua_gettop(L) - top);
|
||||
|
||||
@@ -859,7 +859,7 @@ void World::invoke_lua_expr(int64_t actor_id, int64_t place_id, std::string_view
|
||||
LuaExtStack LS(L, func);
|
||||
|
||||
// create the compiled closure.
|
||||
eng::string error = LS.load(func, datapack, "=invoke");
|
||||
eng::string error = LS.load(func, datapack, "<console>");
|
||||
if (!error.empty()) {
|
||||
// The closure is actually an error message. Do nothing.
|
||||
// This should normally not happen: LuaConsole should filter
|
||||
|
||||
Reference in New Issue
Block a user