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')) {
|
if ((ar.currentline > 0) || (*ar.namewhat != 0) || (*ar.what != 'C')) {
|
||||||
any = true;
|
any = true;
|
||||||
lua_pushliteral(L, "\n\t");
|
lua_pushliteral(L, "\n\t");
|
||||||
lua_pushfstring(L, "%s:", ar.short_src);
|
lua_pushfstring(L, "%s", ar.short_src);
|
||||||
if (ar.currentline > 0)
|
if (ar.currentline > 0 && strcmp(ar.short_src, "<console>"))
|
||||||
lua_pushfstring(L, "%d:", ar.currentline);
|
lua_pushfstring(L, " line %d", ar.currentline);
|
||||||
if (*ar.namewhat != '\0') /* is there a name? */
|
if (*ar.namewhat != '\0') /* is there a name? */
|
||||||
lua_pushfstring(L, " in function " LUA_QS, ar.name);
|
lua_pushfstring(L, " in function " LUA_QS, ar.name);
|
||||||
else {
|
else {
|
||||||
if (*ar.what == 'm') /* main? */
|
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')
|
else if (*ar.what == 'C' || *ar.what == 't')
|
||||||
lua_pushliteral(L, " ?"); /* C function or tail call */
|
lua_pushliteral(L, " in unknown C function");
|
||||||
else
|
else
|
||||||
lua_pushfstring(L, " in function <%s:%d>",
|
lua_pushfstring(L, " in function on line %d", ar.linedefined);
|
||||||
ar.short_src, ar.linedefined);
|
|
||||||
}
|
}
|
||||||
if (1 + lua_gettop(L) - top > 5) {
|
if (1 + lua_gettop(L) - top > 5) {
|
||||||
lua_concat(L, 1 + lua_gettop(L) - top);
|
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);
|
LuaExtStack LS(L, func);
|
||||||
|
|
||||||
// create the compiled closure.
|
// create the compiled closure.
|
||||||
eng::string error = LS.load(func, datapack, "=invoke");
|
eng::string error = LS.load(func, datapack, "<console>");
|
||||||
if (!error.empty()) {
|
if (!error.empty()) {
|
||||||
// The closure is actually an error message. Do nothing.
|
// The closure is actually an error message. Do nothing.
|
||||||
// This should normally not happen: LuaConsole should filter
|
// This should normally not happen: LuaConsole should filter
|
||||||
|
|||||||
Reference in New Issue
Block a user