]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
ReST API: Don't overwrite webob error messages
authorZane Bitter <zbitter@redhat.com>
Mon, 21 Jan 2013 19:04:10 +0000 (20:04 +0100)
committerZane Bitter <zbitter@redhat.com>
Mon, 21 Jan 2013 19:04:15 +0000 (20:04 +0100)
We don't want to replace the entire body of the error messages returned,
just add our detailed description at the end.

Change-Id: I5899854d1ed1766285a5cae2f14c24025ed92e4b
Signed-off-by: Zane Bitter <zbitter@redhat.com>
heat/api/openstack/v1/stacks.py
heat/api/openstack/v1/util.py

index 96d4e8a67f280ebcb27bd9a08f8ee41b45fd36f6..bf329b1fa696d99c2f4769ef40cb0f4bc6a829f8 100644 (file)
@@ -64,15 +64,15 @@ class InstantiationData(object):
         try:
             return template_format.parse(data)
         except ValueError:
-            err_reason = "%s not in valid format" % data_type
-            raise exc.HTTPBadRequest(explanation=err_reason)
+            err_reason = _("%s not in valid format") % data_type
+            raise exc.HTTPBadRequest(err_reason)
 
     def stack_name(self):
         """
         Return the stack name.
         """
         if self.PARAM_STACK_NAME not in self.data:
-            raise exc.HTTPBadRequest(explanation=_("No stack name specified"))
+            raise exc.HTTPBadRequest(_("No stack name specified"))
         return self.data[self.PARAM_STACK_NAME]
 
     def template(self):
@@ -91,9 +91,9 @@ class InstantiationData(object):
                 template_data = urlfetch.get(url)
             except IOError as ex:
                 err_reason = _('Could not retrieve template: %s') % str(ex)
-                raise exc.HTTPBadRequest(explanation=err_reason)
+                raise exc.HTTPBadRequest(err_reason)
         else:
-            raise exc.HTTPBadRequest(explanation=_("No template specified"))
+            raise exc.HTTPBadRequest(_("No template specified"))
 
         return self.format_parse(template_data, 'Template')
 
@@ -184,7 +184,7 @@ class StackController(object):
             return util.remote_error(ex)
 
         if 'Description' in result:
-            raise exc.HTTPBadRequest(explanation=result['Description'])
+            raise exc.HTTPBadRequest(result['Description'])
 
         raise exc.HTTPCreated(location=util.make_url(req, result))
 
@@ -260,7 +260,7 @@ class StackController(object):
             return util.remote_error(ex)
 
         if 'Description' in res:
-            raise exc.HTTPBadRequest(explanation=res['Description'])
+            raise exc.HTTPBadRequest(res['Description'])
 
         raise exc.HTTPAccepted()
 
@@ -279,7 +279,7 @@ class StackController(object):
             return util.remote_error(ex)
 
         if res is not None:
-            raise exc.HTTPBadRequest(explanation=res['Error'])
+            raise exc.HTTPBadRequest(res['Error'])
 
         raise exc.HTTPNoContent()
 
@@ -299,7 +299,7 @@ class StackController(object):
             return util.remote_error(ex)
 
         if 'Error' in result:
-            raise exc.HTTPBadRequest(explanation=result['Error'])
+            raise exc.HTTPBadRequest(result['Error'])
 
         return result
 
@@ -312,7 +312,7 @@ class StackController(object):
         try:
             types = self.engine.list_resource_types(req.context)
         except rpc_common.RemoteError as ex:
-            raise exc.HTTPInternalServerError(explanation=str(ex))
+            raise exc.HTTPInternalServerError(str(ex))
 
         return {'resource_types': types}
 
index 6afea9d3ad2dfbac68a9b2351212d48ec7d8d907..ebe7c2cc53555ec8adce16c2e345c0be4a5f41f6 100644 (file)
@@ -70,7 +70,7 @@ def make_url(req, identity):
         stack_identity = identifier.HeatIdentifier(**identity)
     except ValueError:
         err_reason = _('Invalid Stack address')
-        raise exc.HTTPInternalServerError(explanation=err_reason)
+        raise exc.HTTPInternalServerError(err_reason)
 
     return req.relative_url(stack_identity.url_path(), True)
 
@@ -100,4 +100,4 @@ def remote_error(ex):
 
     Exc = error_map.get(ex.exc_type, exc.HTTPInternalServerError)
 
-    raise Exc(explanation=str(ex))
+    raise Exc(str(ex))