Show the key in "'None' is not a valid Maybe value"
authorPetr Pudlak <pudlak@google.com>
Mon, 28 Oct 2013 14:53:28 +0000 (15:53 +0100)
committerKlaus Aehlig <aehlig@google.com>
Mon, 28 Oct 2013 15:24:49 +0000 (16:24 +0100)
Currently the error message doesn't say which key is affected, which
makes it kind of useless.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

lib/utils/__init__.py

index 4e5b3bd..276c6fc 100644 (file)
@@ -99,7 +99,8 @@ def ForceDictType(target, key_types, allowed_values=None):
 
     if ktype in (constants.VTYPE_STRING, constants.VTYPE_MAYBE_STRING):
       if target[key] is None and ktype == constants.VTYPE_MAYBE_STRING:
-        msg = "'None' is not a valid Maybe value. Use 'VALUE_HS_NOTHING'"
+        msg = ("'None' is not a valid Maybe value for '%s'. "
+               "Use 'VALUE_HS_NOTHING'") % (key, )
         logging.warning(msg)
       elif (target[key] == constants.VALUE_HS_NOTHING
             and ktype == constants.VTYPE_MAYBE_STRING):