mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
fix lua error handling
This commit is contained in:
@@ -1851,8 +1851,12 @@ lua_event::deserialize_( cParser &Input, scene::scratch_data &Scratchpad ) {
|
||||
// run() subclass details
|
||||
void
|
||||
lua_event::run_() {
|
||||
if (lua_func)
|
||||
lua_func(this, m_activator);
|
||||
try {
|
||||
if (lua_func)
|
||||
lua_func(this, m_activator);
|
||||
} catch (...) {
|
||||
ErrorLog(simulation::Lua.get_error());
|
||||
}
|
||||
}
|
||||
|
||||
// export_as_text() subclass details
|
||||
|
||||
10
lua.cpp
10
lua.cpp
@@ -29,6 +29,11 @@ lua::~lua()
|
||||
state = nullptr;
|
||||
}
|
||||
|
||||
std::string lua::get_error()
|
||||
{
|
||||
return std::string(lua_tostring(state, -1));
|
||||
}
|
||||
|
||||
void lua::interpret(std::string file)
|
||||
{
|
||||
if (luaL_dofile(state, file.c_str())) {
|
||||
@@ -43,10 +48,7 @@ void lua::interpret(std::string file)
|
||||
int lua::atpanic(lua_State *s)
|
||||
{
|
||||
std::string err(lua_tostring(s, -1));
|
||||
ErrorLog(std::string(err), logtype::lua);
|
||||
#ifdef _WIN32
|
||||
MessageBox(NULL, err.c_str(), "MaSzyna", MB_OK);
|
||||
#endif
|
||||
ErrorLog(err, logtype::lua);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user