From cfb2bee13b595bd5304b97f846db8b359010b515 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 10 May 2018 19:42:41 -0400 Subject: Added error checking to AutomatingSystem --- src/systems/automating.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/systems/automating.cpp b/src/systems/automating.cpp index 6cec3bf..5233e3e 100644 --- a/src/systems/automating.cpp +++ b/src/systems/automating.cpp @@ -31,7 +31,12 @@ void AutomatingSystem::tick(double dt) continue; } - (*automatable.behavior)(dt); + auto result = (*automatable.behavior)(dt); + if (!result.valid()) + { + sol::error e = result; + throw std::runtime_error(e.what()); + } } } @@ -46,7 +51,13 @@ void AutomatingSystem::initPrototype(id_type prototype) automatable.behavior.reset(); automatable.runner = std::unique_ptr(new sol::thread(sol::thread::create(realizable.scriptEngine.lua_state()))); automatable.behavior = std::unique_ptr(new sol::coroutine(automatable.runner->state()["run"])); - (*automatable.behavior)(script_entity(prototype)); + + auto result = (*automatable.behavior)(script_entity(prototype)); + if (!result.valid()) + { + sol::error e = result; + throw std::runtime_error(e.what()); + } } void AutomatingSystem::initScriptEngine(sol::state& scriptEngine) -- cgit 1.4.1