From 7c920dbe0bc6ce1b67abb9c8aedd573827ef882f Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Mon, 25 Feb 2013 11:14:49 +1100 Subject: [PATCH] Make the exception string a little more useful This partial helps bug #1119883 Change-Id: I247ab39406bcc608c0d66a8140dc198b93491ac1 --- heat/engine/template.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/heat/engine/template.py b/heat/engine/template.py index 301add30ed..31ca9ddf75 100644 --- a/heat/engine/template.py +++ b/heat/engine/template.py @@ -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)