Make Fn::Join give a better error message
When something goes wrong at the moment users are left staring hard at their template trying to figure out whats wrong. We can make this a lot easier by showing them the failed object. Change-Id: If87447b7e160591505a68d857e8ef1751aac3723
This commit is contained in:
parent
c59f659b10
commit
5da90ebee2
@ -302,7 +302,8 @@ class Join(function.Function):
|
||||
if s is None:
|
||||
return ''
|
||||
if not isinstance(s, basestring):
|
||||
raise TypeError(_('Items to join must be strings'))
|
||||
raise TypeError(
|
||||
_('Items to join must be strings %s') % (repr(s)[:200]))
|
||||
return s
|
||||
|
||||
return delim.join(ensure_string(s) for s in strings)
|
||||
|
@ -852,6 +852,14 @@ class ResolveDataTest(HeatTestCase):
|
||||
[' ', ['foo', 'bar']]}, 'baz']]}
|
||||
self.assertEqual('foo bar\nbaz', self.resolve(raw))
|
||||
|
||||
def test_join_not_string(self):
|
||||
snippet = {'Fn::Join': ['\n', [{'Fn::Join':
|
||||
[' ', ['foo', 45]]}, 'baz']]}
|
||||
error = self.assertRaises(TypeError,
|
||||
self.resolve,
|
||||
snippet)
|
||||
self.assertIn('45', six.text_type(error))
|
||||
|
||||
def test_base64_replace(self):
|
||||
raw = {'Fn::Base64': {'Fn::Replace': [
|
||||
{'foo': 'bar'}, 'Meet at the foo']}}
|
||||
|
Loading…
Reference in New Issue
Block a user