summaryrefslogtreecommitdiff
path: root/src/script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script.cpp')
-rw-r--r--src/script.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/script.cpp b/src/script.cpp
index 8b1b7013e..14c23e009 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -35,13 +35,19 @@ LuaError::LuaError(lua_State *L, const std::string &s)
{
m_s = "LuaError: ";
m_s += s + "\n";
+ m_s += script_get_backtrace(L);
+}
+
+std::string script_get_backtrace(lua_State *L)
+{
+ std::string s;
lua_getfield(L, LUA_GLOBALSINDEX, "debug");
if(lua_istable(L, -1)){
lua_getfield(L, -1, "traceback");
if(lua_isfunction(L, -1)){
lua_call(L, 0, 1);
if(lua_isstring(L, -1)){
- m_s += lua_tostring(L, -1);
+ s += lua_tostring(L, -1);
}
lua_pop(L, 1);
}
@@ -50,6 +56,7 @@ LuaError::LuaError(lua_State *L, const std::string &s)
}
}
lua_pop(L, 1);
+ return s;
}
void script_error(lua_State *L, const char *fmt, ...)