More explicit fail messages.

Now if only I could see why I crashed here...
This commit is contained in:
Jason Felds
2012-01-16 13:52:50 -05:00
parent 413992f877
commit c09920bb4b
+6 -1
View File
@@ -70,7 +70,12 @@ const RString &EnumToString( int iVal, int iMax, const char **szNameArray, auto_
// Maybe we should assert on _Invalid? It seems better to make
// the caller check that they're supplying a valid enum value instead of
// returning an inconspicuous garbage value (empty string). -Chris
ASSERT_M( iVal >= 0 && (iVal < iMax || iVal == iMax+1), ssprintf("%i, %i, (%s)", iVal, iMax, szNameArray[0]) );
if (iVal < 0)
FAIL_M(ssprintf("Value %i cannot be negative for enums! Enum hint: %s", iVal, szNameArray[0]));
if (iVal == iMax)
FAIL_M(ssprintf("Value %i cannot be a string with value %i! Enum hint: %s", iVal, iMax, szNameArray[0]));
if (iVal > iMax+1)
FAIL_M(ssprintf("Value %i is past the invalid value %i! Enum hint: %s", iVal, iMax, szNameArray[0]));
return *pNameCache[iVal];
}