Don't do anything undefined if Lua C function throws an exception

This commit is contained in:
Ilari Liusvaara 2012-03-03 11:25:59 +02:00
parent b1c2441da4
commit 5b38dad8fe

View file

@ -51,7 +51,12 @@ namespace
{
void* ptr = lua_touserdata(L, lua_upvalueindex(1));
lua_function* f = reinterpret_cast<lua_function*>(ptr);
return f->invoke(L);
try {
return f->invoke(L);
} catch(std::exception& e) {
lua_pushfstring(L, "Error in internal function: %s", e.what());
lua_error(L);
}
}
//Pushes given table to top of stack, creating if needed.