Don't do anything undefined if Lua C function throws an exception
This commit is contained in:
parent
b1c2441da4
commit
5b38dad8fe
1 changed files with 6 additions and 1 deletions
|
@ -51,7 +51,12 @@ namespace
|
||||||
{
|
{
|
||||||
void* ptr = lua_touserdata(L, lua_upvalueindex(1));
|
void* ptr = lua_touserdata(L, lua_upvalueindex(1));
|
||||||
lua_function* f = reinterpret_cast<lua_function*>(ptr);
|
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.
|
//Pushes given table to top of stack, creating if needed.
|
||||||
|
|
Loading…
Add table
Reference in a new issue