Permalink
Browse files

Fixed argument error logging

Fixed, that second value can not be any type
  • Loading branch information...
Audifire committed May 27, 2015
1 parent c30efc1 commit 846703c68f7b6d137aae36230f9954fcbb148601
@@ -119,23 +119,28 @@ int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
// Got a string argument?
CScriptArgReader argStream ( luaVM );

if ( !argStream.NextIsNil ( ) )
{
bool bCompact = false;
// Read the argument
CLuaArguments JSON;
JSON.ReadArgument ( luaVM, 1 );
argStream.Skip ( 1 );
argStream.ReadBool ( bCompact, false );

// Convert it to a JSON string
std::string strJSON;
if ( JSON.WriteToJSONString ( strJSON, false, bCompact ) )
{
// Return the JSON string
lua_pushstring ( luaVM, strJSON.c_str () );
return 1;
}
if ( !argStream.NextIsNil () )
{
bool bCompact = false;
// Read the argument
CLuaArguments JSON;
JSON.ReadArgument ( luaVM, 1 );
argStream.Skip ( 1 );
argStream.ReadBool ( bCompact, false );

if ( !argStream.HasErrors () )
{
// Convert it to a JSON string
std::string strJSON;
if ( JSON.WriteToJSONString ( strJSON, false, bCompact ) )
{
// Return the JSON string
lua_pushstring ( luaVM, strJSON.c_str () );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
}
else
m_pScriptDebugging->LogBadType ( luaVM );
@@ -370,10 +370,11 @@ int CLuaFunctionDefs::GetTok ( lua_State* luaVM )
return 1;
}

int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
{
int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
{
// Got a string argument?
CScriptArgReader argStream ( luaVM );

if ( !argStream.NextIsNil () )
{
bool bCompact = false;
@@ -383,19 +384,26 @@ int CLuaFunctionDefs::toJSON ( lua_State* luaVM )
argStream.Skip ( 1 );
argStream.ReadBool ( bCompact, false );

// Convert it to a JSON string
std::string strJSON;
if ( JSON.WriteToJSONString ( strJSON, false, bCompact ) )
if ( !argStream.HasErrors () )
{
// Return the JSON string
lua_pushstring ( luaVM, strJSON.c_str () );
return 1;
// Convert it to a JSON string
std::string strJSON;
if ( JSON.WriteToJSONString ( strJSON, false, bCompact ) )
{
// Return the JSON string
lua_pushstring ( luaVM, strJSON.c_str () );
return 1;
}
}
else
m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () );
}

// Failed
lua_pushnil ( luaVM );
return 1;
else
m_pScriptDebugging->LogBadType ( luaVM );

// Failed
lua_pushnil ( luaVM );
return 1;
}


0 comments on commit 846703c

Please sign in to comment.