Skip to content

Commit 5c01f45

Browse files
committed
Fix lua-error log formation for Release build. It also print lua-stack traceback now.
1 parent b9da0e9 commit 5c01f45

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/xrScriptEngine/script_engine.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ struct raii_guard : private Noncopyable
524524
#ifdef DEBUG
525525
static const bool break_on_assert = !!strstr(Core.Params, "-break_on_assert");
526526
#else
527-
static const bool break_on_assert = true;
527+
static const bool break_on_assert = false; // xxx: true will hide real lua error, LuaJIT problem?
528528
#endif
529529
if (!m_error_code) return;
530530
if (break_on_assert)
@@ -756,6 +756,13 @@ int CScriptEngine::lua_pcall_failed(lua_State* L)
756756
{
757757
print_output(L, "", LUA_ERRRUN);
758758
on_error(L);
759+
760+
#ifndef DEBUG // Debug already do it
761+
// Print Lua call stack
762+
const char* lua_error_text = lua_tostring(L, 1); // error text
763+
luaL_traceback(L, L, make_string("%s\n", lua_error_text).c_str(), 1); // add stack trace to it
764+
#endif
765+
759766
#if !XRAY_EXCEPTIONS
760767
xrDebug::Fatal(DEBUG_INFO, "LUA error: %s", lua_isstring(L, -1) ? lua_tostring(L, -1) : "");
761768
#endif
@@ -786,9 +793,8 @@ void CScriptEngine::setup_callbacks()
786793
#if !XRAY_EXCEPTIONS
787794
luabind::set_error_callback(CScriptEngine::lua_error);
788795
#endif
789-
#ifndef MASTER_GOLD
796+
790797
luabind::set_pcall_callback([](lua_State* L) { lua_pushcfunction(L, CScriptEngine::lua_pcall_failed); });
791-
#endif
792798
}
793799
#if !XRAY_EXCEPTIONS
794800
luabind::set_cast_failed_callback(CScriptEngine::lua_cast_failed);

0 commit comments

Comments
 (0)