| 3 | #include <iostream> |
| 4 | |
| 5 | inline void my_panic(sol::optional<std::string> maybe_msg) { |
| 6 | std::cerr << "Lua is in a panic state and will now abort() " |
| 7 | "the application" |
| 8 | << std::endl; |
| 9 | if (maybe_msg) { |
| 10 | const std::string& msg = maybe_msg.value(); |
| 11 | std::cerr << "\terror message: " << msg << std::endl; |
| 12 | } |
| 13 | // When this function exits, Lua will exhibit default |
| 14 | // behavior and abort() |
| 15 | } |
| 16 | |
| 17 | int main(int, char*[]) { |
| 18 | sol::state lua(sol::c_call<decltype(&my_panic), &my_panic>); |