MCPcopy Create free account
hub / github.com/boostorg/leaf / main

Function main

example/lua_callback_exceptions.cpp:148–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148int main()
149{
150 std::shared_ptr<lua_State> L=init_lua_state();
151
152 for( int i=0; i!=10; ++i )
153 {
154 leaf::try_catch(
155
156 [&]
157 {
158 int answer = call_lua(&*L);
159 std::cout << "do_work succeeded, answer=" << answer << '\n';
160
161 },
162
163 []( do_work_error_code e, e_lua_error_message const & msg )
164 {
165 std::cout << "Got do_work_error_code = " << e << ", " << msg.value << "\n";
166 },
167
168 []( e_lua_pcall_error const & err, e_lua_error_message const & msg )
169 {
170 std::cout << "Got e_lua_pcall_error, " << err << ", " << msg.value << "\n";
171 },
172
173 []( leaf::error_info const & unmatched )
174 {
175 std::cerr <<
176 "Unknown failure detected" << std::endl <<
177 "Cryptic diagnostic information follows" << std::endl <<
178 unmatched;
179 } );
180 }
181
182 return 0;
183}

Callers

nothing calls this directly

Calls 3

try_catchFunction · 0.85
init_lua_stateFunction · 0.70
call_luaFunction · 0.70

Tested by

no test coverage detected