changeset 104:d9f9a06e0c49

Make a better error message for "TypeError" exceptions when looking up variables. Otherwise -- if a key exists but if it's not a dict as expected a TypeError is throws that nobody does understand.
author Franz Glasner <f.glasner@feldmann-mg.com>
date Fri, 23 Mar 2018 17:25:21 +0100
parents 2eac386f825a
children 1c2f8a96dec2
files configmix/config.py
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/configmix/config.py	Fri Mar 23 15:54:22 2018 +0100
+++ b/configmix/config.py	Fri Mar 23 17:25:21 2018 +0100
@@ -154,6 +154,8 @@
             v = self[parts[0]]
             for p in parts[1:]:
                 v = v[p]
+        except TypeError:
+            raise KeyError("Configuration variable %r not found (missing intermediate keys?)" % key)
         except KeyError:
             if default is _MARKER:
                 raise KeyError("Configuration variable %r not found" % key)