From: Zane Bitter Date: Mon, 21 Jan 2013 19:04:10 +0000 (+0100) Subject: ReST API: Don't overwrite webob error messages X-Git-Tag: 2014.1~981^2 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=b436b0360d0a13e72fcd799be383da1b416c9893;p=openstack-build%2Fheat-build.git ReST API: Don't overwrite webob error messages 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 --- diff --git a/heat/api/openstack/v1/stacks.py b/heat/api/openstack/v1/stacks.py index 96d4e8a6..bf329b1f 100644 --- a/heat/api/openstack/v1/stacks.py +++ b/heat/api/openstack/v1/stacks.py @@ -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} diff --git a/heat/api/openstack/v1/util.py b/heat/api/openstack/v1/util.py index 6afea9d3..ebe7c2cc 100644 --- a/heat/api/openstack/v1/util.py +++ b/heat/api/openstack/v1/util.py @@ -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))