Skip to content

Commit

Permalink
Fix lua-error log formation for Release build. It also print lua-stac…
Browse files Browse the repository at this point in the history
…k traceback now.
  • Loading branch information
ShokerStlk committed Feb 17, 2017
1 parent b9da0e9 commit 5c01f45
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/xrScriptEngine/script_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ struct raii_guard : private Noncopyable
#ifdef DEBUG
static const bool break_on_assert = !!strstr(Core.Params, "-break_on_assert");
#else
static const bool break_on_assert = true;
static const bool break_on_assert = false; // xxx: true will hide real lua error, LuaJIT problem?
#endif
if (!m_error_code) return;
if (break_on_assert)
Expand Down Expand Up @@ -756,6 +756,13 @@ int CScriptEngine::lua_pcall_failed(lua_State* L)
{
print_output(L, "", LUA_ERRRUN);
on_error(L);

#ifndef DEBUG // Debug already do it
// Print Lua call stack
const char* lua_error_text = lua_tostring(L, 1); // error text
luaL_traceback(L, L, make_string("%s\n", lua_error_text).c_str(), 1); // add stack trace to it
#endif

#if !XRAY_EXCEPTIONS
xrDebug::Fatal(DEBUG_INFO, "LUA error: %s", lua_isstring(L, -1) ? lua_tostring(L, -1) : "");
#endif
Expand Down Expand Up @@ -786,9 +793,8 @@ void CScriptEngine::setup_callbacks()
#if !XRAY_EXCEPTIONS
luabind::set_error_callback(CScriptEngine::lua_error);
#endif
#ifndef MASTER_GOLD

luabind::set_pcall_callback([](lua_State* L) { lua_pushcfunction(L, CScriptEngine::lua_pcall_failed); });
#endif
}
#if !XRAY_EXCEPTIONS
luabind::set_cast_failed_callback(CScriptEngine::lua_cast_failed);
Expand Down

0 comments on commit 5c01f45

Please sign in to comment.