diff options
author | Stefan Radomski <github@mintwerk.de> | 2016-11-23 16:20:34 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2016-11-23 16:20:34 (GMT) |
commit | 7e0257c3f89bf3d3ed35053b89436bba691b60ce (patch) | |
tree | 4fd82a4df0198b1117d11f8901d30b237fe88700 /src/uscxml | |
parent | 14ded59e327f635cc0bbcb634457aafc2f225ad3 (diff) | |
download | uscxml-7e0257c3f89bf3d3ed35053b89436bba691b60ce.zip uscxml-7e0257c3f89bf3d3ed35053b89436bba691b60ce.tar.gz uscxml-7e0257c3f89bf3d3ed35053b89436bba691b60ce.tar.bz2 |
Passing all Lua tests again
Diffstat (limited to 'src/uscxml')
-rw-r--r-- | src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp index 4b7ed67..ed96622 100644 --- a/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp +++ b/src/uscxml/plugins/datamodel/lua/LuaDataModel.cpp @@ -326,6 +326,7 @@ void LuaDataModel::setEvent(const Event& event) { Data LuaDataModel::evalAsData(const std::string& content) { Data data; + ErrorEvent originalError; std::string trimmedExpr = boost::trim_copy(content); @@ -337,21 +338,32 @@ Data LuaDataModel::evalAsData(const std::string& content) { lua_pop(_luaState, retVals); return data; } catch (ErrorEvent e) { + originalError = e; } + int retVals = 0; try { // evaluate again without the return() - int retVals = luaEval(_luaState, trimmedExpr); + retVals = luaEval(_luaState, trimmedExpr); + } catch (ErrorEvent e) { + throw originalError; // we will assume syntax error and throw + } + if (retVals == 0) + throw originalError; // we will assume syntax error and throw + + + try { if (retVals == 1) { data = getLuaAsData(_luaState, luabridge::LuaRef::fromStack(_luaState, -1)); } lua_pop(_luaState, retVals); return data; + + } catch (ErrorEvent e) { + throw e; // we will assume syntax error and throw + } - } catch (ErrorEvent e) { - throw e; // we will assume syntax error and throw - } return data; } @@ -583,4 +595,4 @@ std::string LuaDataModel::andExpressions(std::list<std::string> exprs) { } -}
\ No newline at end of file +} |