From c09920bb4b00f44fa6b0c469cc366066e5ee9e05 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Mon, 16 Jan 2012 13:52:50 -0500 Subject: [PATCH] More explicit fail messages. Now if only I could see why I crashed here... --- src/EnumHelper.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/EnumHelper.cpp b/src/EnumHelper.cpp index 49e837d33a..dec4665019 100644 --- a/src/EnumHelper.cpp +++ b/src/EnumHelper.cpp @@ -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]; }