| 1261 | } |
| 1262 | |
| 1263 | int 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. |
nothing calls this directly
no test coverage detected