more helpful error reporting

This commit is contained in:
Tim Miller 2013-01-29 13:47:49 -08:00
parent d40094e2bd
commit 8fdc1e13f3
2 changed files with 6 additions and 3 deletions

View File

@ -46,8 +46,11 @@ def is_executable(path):
return os.path.isfile(path) and os.access(path, os.X_OK)
def render_moustache(text, config):
r = pystache.Renderer(missing_tags = 'strict')
return r.render(text, config)
try:
r = pystache.Renderer(missing_tags = 'strict')
return r.render(text, config)
except KeyNotFoundError as e:
raise CornfigException("key '%s' does not exist metadata file." % e.key)
def render_executable(path, config):
p = Popen([path], stdin=PIPE, stdout=PIPE, stderr=PIPE)

View File

@ -57,7 +57,7 @@ def test_render_template():
def test_render_moustache():
assert_equals( render_moustache("ab{{x.a}}cd", {"x": {"a": "123"}}), "ab123cd" )
@raises(KeyNotFoundError)
@raises(CornfigException)
def test_render_moustache_bad_key():
render_moustache("{{badkey}}", {})