From: Steven Hardy Date: Wed, 21 Aug 2013 13:09:31 +0000 (+0100) Subject: Fix incorrect use of ServerError X-Git-Tag: 2014.1~141^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=8a9c7a11e008fde92905be1d1183da1b3f3f184c;p=openstack-build%2Fheat-build.git Fix incorrect use of ServerError ServerError is being incorrectly used to report an internal error leading to an error formatting the response, as there's no body specified to the format string. Use exception.Error instead and adjust the message to make the user-visible response clearer. Fixes bug #1214457 Change-Id: I83435686170c4f40658968a35f1faa303f50f4a4 --- diff --git a/heat/engine/parser.py b/heat/engine/parser.py index 56a60b6b..469366de 100644 --- a/heat/engine/parser.py +++ b/heat/engine/parser.py @@ -34,7 +34,6 @@ from heat.db import api as db_api from heat.openstack.common import log as logging from heat.openstack.common.gettextutils import _ -from heat.common.exception import ServerError from heat.common.exception import StackValidationFailed logger = logging.getLogger(__name__) @@ -259,7 +258,7 @@ class Stack(object): for res in self: try: result = res.validate() - except ServerError as ex: + except exception.Error as ex: logger.exception(ex) raise ex except Exception as ex: diff --git a/heat/engine/resources/nova_utils.py b/heat/engine/resources/nova_utils.py index daf4d770..1e30a625 100644 --- a/heat/engine/resources/nova_utils.py +++ b/heat/engine/resources/nova_utils.py @@ -66,7 +66,8 @@ def get_image_id(nova_client, image_identifier): try: image_list = nova_client.images.list() except clients.novaclient.exceptions.ClientException as ex: - raise exception.ServerError(message=str(ex)) + raise exception.Error( + message="Error retrieving image list from nova: %s" % str(ex)) image_names = dict( (o.id, o.name) for o in image_list if o.name == image_identifier) diff --git a/heat/tests/test_validate.py b/heat/tests/test_validate.py index 12b424a6..e681c0cb 100644 --- a/heat/tests/test_validate.py +++ b/heat/tests/test_validate.py @@ -817,8 +817,7 @@ class validateTest(HeatTestCase): instances.Instance.nova().AndReturn(self.fc) self.m.ReplayAll() - self.assertRaises(exception.ServerError, - stack.validate) + self.assertRaises(exception.Error, stack.validate) self.m.VerifyAll() def test_validate_unique_logical_name(self):