# HG changeset patch # User Jeff Hammel # Date 1332876418 25200 # Node ID 346c702f63db535734f413145cbbd21dea47b573 # Parent bb5f4eeb56c5b90bd3a84156b498943de222ccac better error message diff -r bb5f4eeb56c5 -r 346c702f63db configuration/config.py --- a/configuration/config.py Tue Mar 27 12:16:43 2012 -0700 +++ b/configuration/config.py Tue Mar 27 12:26:58 2012 -0700 @@ -32,6 +32,9 @@ class ConfigurationProviderException(Exception): """exception raised when a configuration provider is missing, etc""" +class TypeCastException(Exception): + """exception raised when a configuration item cannot be coerced to a type""" + ### configuration providers for serialization/deserialization configuration_providers = [] @@ -204,7 +207,10 @@ for key, value in config.items(): _type = self.options[key].get('type') if _type is not None: - config[key] = _type(value) + try: + config[key] = _type(value) + except BaseException, e: + raise TypeCastException("Could not coerce %s, %s, to type %s: %s" % (key, value, _type.__name__, e)) return config