| 7434 | } |
| 7435 | |
| 7436 | inline int call_exception_handler(lua_State* L, optional<const std::exception&> maybe_ex, string_view what) { |
| 7437 | lua_getglobal(L, default_exception_handler_name()); |
| 7438 | type t = static_cast<type>(lua_type(L, -1)); |
| 7439 | if (t != type::lightuserdata) { |
| 7440 | lua_pop(L, 1); |
| 7441 | return default_exception_handler(L, std::move(maybe_ex), std::move(what)); |
| 7442 | } |
| 7443 | void* vfunc = lua_touserdata(L, -1); |
| 7444 | lua_pop(L, 1); |
| 7445 | if (vfunc == nullptr) { |
| 7446 | return default_exception_handler(L, std::move(maybe_ex), std::move(what)); |
| 7447 | } |
| 7448 | exception_handler_function exfunc = reinterpret_cast<exception_handler_function>(vfunc); |
| 7449 | return exfunc(L, std::move(maybe_ex), std::move(what)); |
| 7450 | } |
| 7451 | |
| 7452 | #ifdef SOL_NO_EXCEPTIONS |
| 7453 | template <lua_CFunction f> |
no test coverage detected