From 12e38d98d5ae5a5ffd80e969172fb468af044211 Mon Sep 17 00:00:00 2001 From: Justin Shepherd Date: Tue, 15 Jan 2013 04:05:11 +0000 Subject: Cleaning up exception handling bug 1094035 Change-Id: I91e134a3632e6b3314fe90d25e2df780aaba54d1 --- nova/api/openstack/compute/servers.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index d3a6fc8a9..f0fdb5a15 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -538,10 +538,10 @@ class Controller(wsgi.Controller): marker=marker) except exception.MarkerNotFound as e: msg = _('marker [%s] not found') % marker - raise webob.exc.HTTPBadRequest(explanation=msg) + raise exc.HTTPBadRequest(explanation=msg) except exception.FlavorNotFound as e: msg = _("Flavor could not be found") - raise webob.exc.HTTPUnprocessableEntity(explanation=msg) + raise exc.HTTPUnprocessableEntity(explanation=msg) if is_detail: self._add_instance_faults(context, instance_list) @@ -828,21 +828,24 @@ class Controller(wsgi.Controller): try: min_count = int(min_count) except ValueError: - raise webob.exc.HTTPBadRequest(_('min_count must be an ' - 'integer value')) + msg = _('min_count must be an integer value') + raise exc.HTTPBadRequest(explanation=msg) if min_count < 1: - raise webob.exc.HTTPBadRequest(_('min_count must be > 0')) + msg = _('min_count must be > 0') + raise exc.HTTPBadRequest(explanation=msg) try: max_count = int(max_count) except ValueError: - raise webob.exc.HTTPBadRequest(_('max_count must be an ' - 'integer value')) + msg = _('max_count must be an integer value') + raise exc.HTTPBadRequest(explanation=msg) if max_count < 1: - raise webob.exc.HTTPBadRequest(_('max_count must be > 0')) + msg = _('max_count must be > 0') + raise exc.HTTPBadRequest(explanation=msg) if min_count > max_count: - raise webob.exc.HTTPBadRequest(_('min_count must be <= max_count')) + msg = _('min_count must be <= max_count') + raise exc.HTTPBadRequest(explanation=msg) auto_disk_config = False if self.ext_mgr.is_loaded('OS-DCF'): @@ -1202,7 +1205,8 @@ class Controller(wsgi.Controller): try: body = body['rebuild'] except (KeyError, TypeError): - raise exc.HTTPBadRequest(_("Invalid request body")) + msg = _('Invalid request body') + raise exc.HTTPBadRequest(explanation=msg) try: image_href = body["imageRef"] -- cgit