]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Make the exception string a little more useful
authorAngus Salkeld <asalkeld@redhat.com>
Mon, 25 Feb 2013 00:14:49 +0000 (11:14 +1100)
committerAngus Salkeld <asalkeld@redhat.com>
Mon, 25 Feb 2013 00:15:17 +0000 (11:15 +1100)
This partial helps bug #1119883

Change-Id: I247ab39406bcc608c0d66a8140dc198b93491ac1

heat/engine/template.py

index 301add30ed3162fa535d5ea5221232d6e5a8e447..31ca9ddf75e42017af49049efb6b93925c37d8c1 100644 (file)
@@ -161,7 +161,13 @@ class Template(collections.Mapping):
         def handle_join(args):
             if not isinstance(args, (list, tuple)):
                 raise TypeError('Arguments to "Fn::Join" must be a list')
-            delim, items = args
+            try:
+                delim, items = args
+            except ValueError as ex:
+                example = '"Fn::Join" : [ " ", [ "str1", "str2"]]'
+                raise ValueError('Incorrect arguments to "Fn::Join" %s: %s' %
+                                ('should be', example))
+
             if not isinstance(items, (list, tuple)):
                 raise TypeError('Arguments to "Fn::Join" not fully resolved')
             reduced = []
@@ -189,7 +195,14 @@ class Template(collections.Mapping):
         def handle_join(args):
             if not isinstance(args, (list, tuple)):
                 raise TypeError('Arguments to "Fn::Join" must be a list')
-            delim, strings = args
+
+            try:
+                delim, strings = args
+            except ValueError as ex:
+                example = '"Fn::Join" : [ " ", [ "str1", "str2"]]'
+                raise ValueError('Incorrect arguments to "Fn::Join" %s: %s' %
+                                ('should be', example))
+
             if not isinstance(strings, (list, tuple)):
                 raise TypeError('Arguments to "Fn::Join" not fully resolved')
             return delim.join(strings)