]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Fix incorrect use of ServerError
authorSteven Hardy <shardy@redhat.com>
Wed, 21 Aug 2013 13:09:31 +0000 (14:09 +0100)
committerSteven Hardy <shardy@redhat.com>
Wed, 21 Aug 2013 13:12:11 +0000 (14:12 +0100)
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

heat/engine/parser.py
heat/engine/resources/nova_utils.py
heat/tests/test_validate.py

index 56a60b6b0eccb33d28a4688939ad064dfc656231..469366de2562841845fff5e8294eea8a1f820511 100644 (file)
@@ -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:
index daf4d770a7f3f7595704c806ffd10d0d6c0dff72..1e30a6255e640c5e6eccf15ad2dab437d05b47b4 100644 (file)
@@ -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)
index 12b424a6eef4862704131d299d2913d0c4318298..e681c0cb297b04db5c63032fdbeef3d284c564fc 100644 (file)
@@ -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):