EgtGeneral 2.3d2 :

- corretto controllo errori nelle chiamate di esecuzione lua (errore introdotto nella versione 2.3b1).
This commit is contained in:
Dario Sassi
2021-04-10 08:54:44 +00:00
parent 51f0c9c2b7
commit 12ffb3dbd7
2 changed files with 9 additions and 9 deletions
+9 -9
View File
@@ -169,7 +169,7 @@ LuaMgr::EvalExpr( const string& sExpr, double& dVal)
return true ;
}
else {
m_sLastError = "Error infinite or not a number" ;
m_sLastError = "EvalExpr(number): Error infinite or not a number" ;
// lo scrivo nel log
LOG_ERROR( GetEGnLogger(), m_sLastError.c_str())
return false ;
@@ -179,7 +179,7 @@ LuaMgr::EvalExpr( const string& sExpr, double& dVal)
else {
// recupero il messaggio di errore
const char* szErr = lua_tostring( m_pL, -1) ;
m_sLastError = ( szErr != nullptr) ? szErr : "Error not a number" ;
m_sLastError = string( "EvalExpr(number): ") + (( szErr != nullptr) ? szErr : "Error not a number") ;
lua_pop( m_pL, 1) ;
// lo scrivo nel log
LOG_ERROR( GetEGnLogger(), m_sLastError.c_str())
@@ -199,7 +199,7 @@ LuaMgr::EvalExpr( const string& sExpr, string& sVal)
// valuto l'espressione
int nErr = luaL_loadstring( m_pL, sEval.c_str()) ;
if ( nErr == LUA_OK)
lua_pcall( m_pL, 0, 1, 0) ;
nErr = lua_pcall( m_pL, 0, 1, 0) ;
// senza errori
if ( nErr == LUA_OK && lua_type( m_pL, -1) == LUA_TSTRING) {
sVal = lua_tostring( m_pL, -1) ;
@@ -211,7 +211,7 @@ LuaMgr::EvalExpr( const string& sExpr, string& sVal)
else {
// recupero il messaggio di errore
const char* szErr = lua_tostring( m_pL, -1) ;
m_sLastError = ( szErr != nullptr) ? szErr : "Error not a string" ;
m_sLastError = string( "EvalExpr(string): ") + (( szErr != nullptr) ? szErr : "Error not a string") ;
lua_pop( m_pL, 1) ;
// lo scrivo nel log
LOG_ERROR( GetEGnLogger(), m_sLastError.c_str())
@@ -229,7 +229,7 @@ LuaMgr::ExecLine( const string& sLine)
// eseguo la linea
int nErr = luaL_loadstring( m_pL, sLine.c_str()) ;
if ( nErr == LUA_OK)
lua_pcall( m_pL, 0, LUA_MULTRET, 0) ;
nErr = lua_pcall( m_pL, 0, LUA_MULTRET, 0) ;
// senza errori
if ( nErr == LUA_OK) {
m_sLastError.clear() ;
@@ -239,7 +239,7 @@ LuaMgr::ExecLine( const string& sLine)
else {
// recupero il messaggio di errore
const char* szErr = lua_tostring( m_pL, -1) ;
m_sLastError = ( szErr != nullptr) ? szErr : "Error unknown" ;
m_sLastError = string( "ExecLine: ") + (( szErr != nullptr) ? szErr : "Error unknown") ;
lua_pop( m_pL, 1) ;
// lo scrivo nel log
LOG_ERROR( GetEGnLogger(), m_sLastError.c_str())
@@ -257,7 +257,7 @@ LuaMgr::ExecFile( const string& sFile)
// eseguo la linea
int nErr = luaL_loadfile( m_pL, sFile.c_str()) ;
if ( nErr == LUA_OK)
lua_pcall( m_pL, 0, LUA_MULTRET, 0) ;
nErr = lua_pcall( m_pL, 0, LUA_MULTRET, 0) ;
// senza errori
if ( nErr == LUA_OK) {
m_sLastError.clear() ;
@@ -267,7 +267,7 @@ LuaMgr::ExecFile( const string& sFile)
else {
// recupero il messaggio di errore
const char* szErr = lua_tostring( m_pL, -1) ;
m_sLastError = ( szErr != nullptr) ? szErr : "Error unknown" ;
m_sLastError = (( szErr != nullptr) ? szErr : "Error unknown") ;
lua_pop( m_pL, 1) ;
// lo scrivo nel log
LOG_ERROR( GetEGnLogger(), m_sLastError.c_str())
@@ -307,4 +307,4 @@ void
LuaMgr::LogError( const string& sErr) const
{
LOG_ERROR( GetEGnLogger(), sErr.c_str())
}
}