Permalink
Browse files

better error reporting for url-ini, url-python, and url-json

  • Loading branch information...
1 parent fd945ed commit 96baca9f92649369c094c2a743658a836eee478e @piranha committed Aug 19, 2013
Showing with 8 additions and 2 deletions.
  1. +8 −2 nomad/utils.py
View
10 nomad/utils.py
@@ -89,7 +89,10 @@ def get_python(path):
else:
# load from sys.path
mod = __import__(pypath, {}, {}, [''])
- return reduce(lambda x, y: getattr(x, y), attr.split('.'), mod)
+ try:
+ return reduce(lambda x, y: getattr(x, y), attr.split('.'), mod)
+ except AttributeError:
+ raise AttributeError("No attr '%s' in module %s" % (attr, pypath))
def get_file(path):
@@ -113,7 +116,10 @@ def get_ini(path):
section, key = path.split('.')
cfg = ConfigParser(interpolation=ExtendedInterpolation())
cfg.read([fn])
- return cfg[section][key]
+ try:
+ return cfg[section][key]
+ except KeyError:
+ raise KeyError('%s not found in %s' % (path, fn))
URLTYPES = {

0 comments on commit 96baca9

Please sign in to comment.