From c6388e5be6d2e088527bc7479897e3fbc262d69d Mon Sep 17 00:00:00 2001 From: milek7 Date: Tue, 19 Feb 2019 01:19:40 +0100 Subject: [PATCH] write lua errors to errorlog --- lua.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lua.cpp b/lua.cpp index 11872023..33daabca 100644 --- a/lua.cpp +++ b/lua.cpp @@ -31,8 +31,10 @@ lua::~lua() void lua::interpret(std::string file) { - if (luaL_dofile(state, file.c_str())) - throw std::runtime_error(lua_tostring(state, -1)); + if (luaL_dofile(state, file.c_str())) { + char *str = lua_tostring(state, -1); + ErrorLog(std::string(str), logtype::lua); + } } // NOTE: we cannot throw exceptions in callbacks @@ -41,7 +43,7 @@ void lua::interpret(std::string file) int lua::atpanic(lua_State *s) { std::string err(lua_tostring(s, -1)); - ErrorLog(err); + ErrorLog(std::string(err), logtype::lua); #ifdef _WIN32 MessageBox(NULL, err.c_str(), "MaSzyna", MB_OK); #endif @@ -52,7 +54,7 @@ int lua::openffi(lua_State *s) { if (luaL_dostring(s, lua_ffi)) { - ErrorLog(std::string(lua_tostring(s, -1))); + ErrorLog(std::string(lua_tostring(s, -1)), logtype::lua); return 0; } return 1;