Skip to content

Commit

Permalink
simplified lua stack clear wrapper, added log->flush before exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kraynyukhov committed Aug 27, 2018
1 parent 141d301 commit 1e458df
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions include/abstract/ApplicationContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ namespace abstract

void cleanLuaStack()
{
while(lua_gettop(mLState))
{
lua_pop(mLState,1);
}
lua_pop(mLState,lua_gettop(mLState));
}

const bool require(const std::string& module_name)
Expand Down Expand Up @@ -77,14 +74,18 @@ namespace abstract
switch(ret)
{
case LUA_ERRRUN:
itc::getLog()->flush();
throw std::runtime_error(std::string("Lua runtime error on "+on+" "+module_or_method+": ")+std::string(lua_tostring(mLState,lua_gettop(mLState))));
break;
case LUA_ERRMEM:
itc::getLog()->flush();
throw std::system_error(ENOMEM,std::system_category(),"Not enough memory to "+on+" "+module_or_method+": "+std::string(lua_tostring(mLState,lua_gettop(mLState))));
case LUA_ERRERR:
itc::getLog()->flush();
throw std::logic_error("Error in lua error handler on "+on+" "+module_or_method+": "+std::string(lua_tostring(mLState,lua_gettop(mLState))));
break;
default:
itc::getLog()->flush();
throw std::system_error(EINVAL,std::system_category(),"Unknown error on lua_pcall()");
}
}
Expand Down

0 comments on commit 1e458df

Please # to comment.