better error messaging.
This commit is contained in:
parent
dab1539983
commit
598e4760db
@ -55,7 +55,10 @@ def render_executable(path, config):
|
||||
raise CornfigException("config script failed: %s\n\nwith output:\n\n%s" % (path, e.output))
|
||||
|
||||
def read_config(path):
|
||||
return json.loads(open(path).read())
|
||||
try:
|
||||
return json.loads(open(path).read())
|
||||
except:
|
||||
raise CornfigException("invalid metadata file: %s" % path)
|
||||
|
||||
# flatten a nested hash into a one-level hash
|
||||
# {x: {a: b} } => {x.a: b}
|
||||
@ -103,7 +106,7 @@ def main():
|
||||
|
||||
install_cornfig(options.metadata_path, options.template_root, options.out_root)
|
||||
except CornfigException as e:
|
||||
logging.error(e.message())
|
||||
logging.error(e)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -83,7 +83,7 @@ def test_read_config():
|
||||
t.flush()
|
||||
assert_equals( read_config(t.name), d )
|
||||
|
||||
@raises(ValueError)
|
||||
@raises(CornfigException)
|
||||
def test_read_config_bad_json():
|
||||
with tempfile.NamedTemporaryFile() as t:
|
||||
t.write("{{{{")
|
||||
|
Loading…
x
Reference in New Issue
Block a user