MCPcopy Create free account
hub / github.com/DFHack/dfhack / CallWithCatch

Method CallWithCatch

library/LuaTypes.cpp:1263–1277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1261}
1262
1263int Lua::CallWithCatch(lua_State *state, int (*fn)(lua_State*), const char *context)
1264{
1265 if (!context)
1266 context = "native code";
1267
1268 try {
1269 return fn(state);
1270 }
1271 catch (Error::All &e) {
1272 return luaL_error(state, "%s: %s", context, e.what());
1273 }
1274 catch (std::exception &e) {
1275 return luaL_error(state, "%s: C++ exception: %s", context, e.what());
1276 }
1277}
1278
1279/**
1280 * Push a closure invoking the given function.

Callers

nothing calls this directly

Calls 2

luaL_errorFunction · 0.85
whatMethod · 0.45

Tested by

no test coverage detected