changeset 131:fedcb71bfa87 draft

better error message in check_type(), tell the types by name instead of by number
author s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b>
date Wed, 10 Feb 2010 19:46:04 +0000
parents 93e6a18bfe76
children 87d71afbed20
files json/json_spirit_value.h
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/json/json_spirit_value.h
+++ b/json/json_spirit_value.h
@@ -24,6 +24,7 @@
 namespace json_spirit
 {
     enum Value_type{ obj_type, array_type, str_type, bool_type, int_type, real_type, null_type };
+    static const char* Value_type_name[]={"obj", "array", "str", "bool", "int", "real", "null"};
 
     template< class Config >    // Config determines whether the value uses std::string or std::wstring and
                                 // whether JSON Objects are represented as vectors or maps
@@ -341,7 +342,8 @@
         {
             std::ostringstream os;
 
-            os << "value type is " << type() << " not " << vtype;
+            /// satoshi: tell the types by name instead of by number
+            os << "value is type " << Value_type_name[type()] << ", expected " << Value_type_name[vtype];
 
             throw std::runtime_error( os.str() );
         }