diff --git a/heat/engine/cfn/functions.py b/heat/engine/cfn/functions.py index 558b172529..2bf6389be9 100644 --- a/heat/engine/cfn/functions.py +++ b/heat/engine/cfn/functions.py @@ -85,8 +85,9 @@ class ParamRef(function.Function): try: return self.parameters[param_name] - except (KeyError, ValueError): - raise exception.UserParameterMissing(key=param_name) + except KeyError: + raise exception.InvalidTemplateReference(resource=param_name, + key='unknown') class ResourceRef(function.Function): @@ -98,10 +99,14 @@ class ResourceRef(function.Function): { "Ref" : "" } ''' - def _resource(self): + def _resource(self, path='unknown'): resource_name = function.resolve(self.args) - return self.stack[resource_name] + try: + return self.stack[resource_name] + except KeyError: + raise exception.InvalidTemplateReference(resource=resource_name, + key=path) def result(self): return self._resource().FnGetRefId() @@ -150,15 +155,14 @@ class GetAtt(function.Function): return resource_name, attribute - def _resource(self): + def _resource(self, path='unknown'): resource_name = function.resolve(self._resource_name) try: return self.stack[resource_name] except KeyError: - raise exception.InvalidTemplateAttribute( - resource=resource_name, - key=function.resolve(self._attribute)) + raise exception.InvalidTemplateReference(resource=resource_name, + key=path) def result(self): attribute = function.resolve(self._attribute) diff --git a/heat/engine/parameters.py b/heat/engine/parameters.py index 910bacc29a..cc623c2af7 100644 --- a/heat/engine/parameters.py +++ b/heat/engine/parameters.py @@ -220,7 +220,7 @@ class Parameter(object): if self.has_default(): return self.default() - raise KeyError(_('Missing parameter %s') % self.name) + raise exception.UserParameterMissing(key=self.name) def hidden(self): ''' diff --git a/heat/tests/test_hot.py b/heat/tests/test_hot.py index 2d2d84820b..cc380097fb 100644 --- a/heat/tests/test_hot.py +++ b/heat/tests/test_hot.py @@ -649,7 +649,7 @@ class StackTest(test_parser.StackTest): self.stack.state) snippet = {'Value': {'get_attr': ['resource2', 'who_cares']}} - self.assertRaises(exception.InvalidTemplateAttribute, + self.assertRaises(exception.InvalidTemplateReference, self.resolve, snippet) @utils.stack_delete_after