made "error" accessible in the Lua state

We need to expose `error()` in Lua in order to let it call the error handler function. However, for that the base library needs to be available in the Lua state.
 
Without this fix the output of the program is
`call failed, sol::error::what() is Handled this message: [string "..."]:7: attempt to call a nil value (global 'error')`
while it's supposed to be
`call failed, sol::error::what() is Handled this message: [string "..."]:7: negative number detected`
This commit is contained in:
sjaustirni 2017-04-20 22:22:35 +02:00 committed by The Phantom Derpstorm
parent 3d5f80e35a
commit eebda40507

View File

@ -7,6 +7,7 @@ int main() {
std::cout << "=== protected_functions example ===" << std::endl;
sol::state lua;
lua.open_libraries(sol::lib::base);
// A complicated function which can error out
// We define both in terms of Lua code