better error message
This commit is contained in:
@@ -19,11 +19,22 @@ int CheckEnum( lua_State *L, LuaReference &table, int iPos, int iInvalid, const
|
|||||||
// and not silently result in nil, or an out-of-bounds value.
|
// and not silently result in nil, or an out-of-bounds value.
|
||||||
if( unlikely(lua_isnil(L, -1)) )
|
if( unlikely(lua_isnil(L, -1)) )
|
||||||
{
|
{
|
||||||
// XXX: show string if a string, otherwise the type
|
|
||||||
lua_pushvalue( L, iPos );
|
|
||||||
RString sGot;
|
RString sGot;
|
||||||
LuaHelpers::Pop( L, sGot );
|
if( lua_isstring(L, iPos) )
|
||||||
LuaHelpers::Push( L, ssprintf("Expected %s; got \"%s\"", szType, sGot.c_str() ) );
|
{
|
||||||
|
/* We were given a string, but it wasn't a valid value for this enum. Show
|
||||||
|
* the string. */
|
||||||
|
lua_pushvalue( L, iPos );
|
||||||
|
LuaHelpers::Pop( L, sGot );
|
||||||
|
sGot = ssprintf( "\"%s\"", sGot.c_str() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We didn't get a string. Show the type. */
|
||||||
|
luaL_pushtype( L, iPos );
|
||||||
|
LuaHelpers::Pop( L, sGot );
|
||||||
|
}
|
||||||
|
LuaHelpers::Push( L, ssprintf("Expected %s; got %s", szType, sGot.c_str() ) );
|
||||||
lua_error( L );
|
lua_error( L );
|
||||||
}
|
}
|
||||||
int iRet = lua_tointeger( L, -1 );
|
int iRet = lua_tointeger( L, -1 );
|
||||||
|
|||||||
Reference in New Issue
Block a user