Make lua tracebacks a little better

This commit is contained in:
2026-05-21 19:24:11 -04:00
parent 2bfa3024f1
commit 521d4726ad
2 changed files with 7 additions and 8 deletions

View File

@@ -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);