Last active
September 30, 2018 00:06
-
-
Save grandemk/3efd707fb77a1332f45e9839b650f0a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "sol.hpp" | |
#include <iostream> | |
#include <string> | |
using std::cout; | |
using std::endl; | |
using std::string; | |
int main() | |
{ | |
sol::state lua; | |
string code = "unknown_func()"; | |
sol::coroutine co = lua.load(code); | |
while(co) | |
{ | |
cout << "C++ - Resuming coroutine" << endl; | |
auto result = co(); | |
cout << "C++ Coroutine state: " << sol::to_string(co.status()) << std::endl; | |
// how do I get the error string ? | |
// answer: | |
if(!result.valid()) | |
sol:error err = result; | |
cout << "error: " << err.what() << endl | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ g++ -std=c++14 coroutine_error_handling.cpp ext/liblua.a -I ext/lua-5.3.5/src -ldl
$ ./a.out
C++ - Resuming coroutine
C++ Coroutine state: runtime