Merge "Pass errors from *_format.parse() to the caller"
This commit is contained in:
commit
3dc2ce01de
|
@ -71,9 +71,10 @@ class InstantiationData(object):
|
|||
return environment_format.parse(data)
|
||||
else:
|
||||
return template_format.parse(data)
|
||||
except ValueError:
|
||||
err_reason = _("%s not in valid format") % data_type
|
||||
raise exc.HTTPBadRequest(err_reason)
|
||||
except ValueError as parse_ex:
|
||||
mdict = {'type': data_type, 'error': parse_ex}
|
||||
msg = _("%(type)s not in valid format: %(error)s") % mdict
|
||||
raise exc.HTTPBadRequest(msg)
|
||||
|
||||
def stack_name(self):
|
||||
"""
|
||||
|
|
|
@ -71,6 +71,20 @@ class InstantiationDataTest(HeatTestCase):
|
|||
stacks.InstantiationData.format_parse,
|
||||
'!@#$%^¬ json', 'Garbage')
|
||||
|
||||
def test_format_parse_invalid_message(self):
|
||||
# make sure the parser error gets through to the caller.
|
||||
bad_temp = '''
|
||||
parameters:
|
||||
KeyName:
|
||||
type: string
|
||||
description: bla
|
||||
'''
|
||||
|
||||
parse_ex = self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
stacks.InstantiationData.format_parse,
|
||||
bad_temp, 'foo')
|
||||
self.assertIn('line 3, column 3', str(parse_ex))
|
||||
|
||||
def test_stack_name(self):
|
||||
body = {'stack_name': 'wibble'}
|
||||
data = stacks.InstantiationData(body)
|
||||
|
|
Loading…
Reference in New Issue