diff options
| author | Chris Yeoh <cyeoh@au1.ibm.com> | 2013-06-07 11:07:49 +0930 |
|---|---|---|
| committer | Christopher Yeoh <cyeoh@au1.ibm.com> | 2013-06-08 11:00:42 +0930 |
| commit | 863b3e45401becbd4ad7452f2bdf43ec2ff87732 (patch) | |
| tree | 5f5a6fa255829f510f2407c8a89c65addc965eb8 /nova/api | |
| parent | 7d423d3c919cd8b3526010981b0037e7579132d1 (diff) | |
| download | nova-863b3e45401becbd4ad7452f2bdf43ec2ff87732.tar.gz nova-863b3e45401becbd4ad7452f2bdf43ec2ff87732.tar.xz nova-863b3e45401becbd4ad7452f2bdf43ec2ff87732.zip | |
Cleanup nova exception message conversion
Fix cases where setting the explanation for an HTTP exception
based on a Nova exception was done using str(ANovaException)
rather than using ANovaException.format_message()
Change-Id: Ia8a361fcb088dcf3c17be0d296aee494b9f063d7
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/volumes.py | 2 | ||||
| -rw-r--r-- | nova/api/openstack/compute/images.py | 4 | ||||
| -rw-r--r-- | nova/api/openstack/compute/plugins/v3/servers.py | 8 | ||||
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 8 |
4 files changed, 11 insertions, 11 deletions
diff --git a/nova/api/openstack/compute/contrib/volumes.py b/nova/api/openstack/compute/contrib/volumes.py index 3ede9e4a4..0c629f068 100644 --- a/nova/api/openstack/compute/contrib/volumes.py +++ b/nova/api/openstack/compute/contrib/volumes.py @@ -255,7 +255,7 @@ class VolumeController(wsgi.Controller): availability_zone=availability_zone ) except exception.InvalidInput as err: - raise exc.HTTPBadRequest(explanation=str(err)) + raise exc.HTTPBadRequest(explanation=err.format_message()) # TODO(vish): Instance should be None at db layer instead of # trying to lazy load, but for now we turn it into diff --git a/nova/api/openstack/compute/images.py b/nova/api/openstack/compute/images.py index 4dba0a6c2..e0c4f7465 100644 --- a/nova/api/openstack/compute/images.py +++ b/nova/api/openstack/compute/images.py @@ -181,7 +181,7 @@ class Controller(wsgi.Controller): images = self._image_service.detail(context, filters=filters, **page_params) except exception.Invalid as e: - raise webob.exc.HTTPBadRequest(explanation=str(e)) + raise webob.exc.HTTPBadRequest(explanation=e.format_message()) return self._view_builder.index(req, images) @wsgi.serializers(xml=ImagesTemplate) @@ -201,7 +201,7 @@ class Controller(wsgi.Controller): images = self._image_service.detail(context, filters=filters, **page_params) except exception.Invalid as e: - raise webob.exc.HTTPBadRequest(explanation=str(e)) + raise webob.exc.HTTPBadRequest(explanation=e.format_message()) req.cache_db_items('images', images, 'id') return self._view_builder.detail(req, images) diff --git a/nova/api/openstack/compute/plugins/v3/servers.py b/nova/api/openstack/compute/plugins/v3/servers.py index d9b2d4a3b..a0bc52e3e 100644 --- a/nova/api/openstack/compute/plugins/v3/servers.py +++ b/nova/api/openstack/compute/plugins/v3/servers.py @@ -518,7 +518,7 @@ class ServersController(wsgi.Controller): try: servers = self._get_servers(req, is_detail=False) except exception.Invalid as err: - raise exc.HTTPBadRequest(explanation=str(err)) + raise exc.HTTPBadRequest(explanation=err.format_message()) return servers @wsgi.serializers(xml=ServersTemplate) @@ -527,7 +527,7 @@ class ServersController(wsgi.Controller): try: servers = self._get_servers(req, is_detail=True) except exception.Invalid as err: - raise exc.HTTPBadRequest(explanation=str(err)) + raise exc.HTTPBadRequest(explanation=err.format_message()) return servers def _add_instance_faults(self, ctxt, instances): @@ -630,7 +630,7 @@ class ServersController(wsgi.Controller): utils.check_string_length(value, name, min_length=1, max_length=max_length) except exception.InvalidInput as e: - raise exc.HTTPBadRequest(explanation=str(e)) + raise exc.HTTPBadRequest(explanation=e.format_message()) def _validate_server_name(self, value): self._check_string_length(value, 'Server name', max_length=255) @@ -1460,7 +1460,7 @@ class ServersController(wsgi.Controller): common.raise_http_conflict_for_instance_invalid_state(state_error, 'createImage') except exception.Invalid as err: - raise exc.HTTPBadRequest(explanation=str(err)) + raise exc.HTTPBadRequest(explanation=err.format_message()) # build location of newly-created image entity image_id = str(image['id']) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 41c3b92a5..a996a843b 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -471,7 +471,7 @@ class Controller(wsgi.Controller): try: servers = self._get_servers(req, is_detail=False) except exception.Invalid as err: - raise exc.HTTPBadRequest(explanation=str(err)) + raise exc.HTTPBadRequest(explanation=err.format_message()) return servers @wsgi.serializers(xml=ServersTemplate) @@ -480,7 +480,7 @@ class Controller(wsgi.Controller): try: servers = self._get_servers(req, is_detail=True) except exception.Invalid as err: - raise exc.HTTPBadRequest(explanation=str(err)) + raise exc.HTTPBadRequest(explanation=err.format_message()) return servers def _add_instance_faults(self, ctxt, instances): @@ -583,7 +583,7 @@ class Controller(wsgi.Controller): utils.check_string_length(value, name, min_length=1, max_length=max_length) except exception.InvalidInput as e: - raise exc.HTTPBadRequest(explanation=str(e)) + raise exc.HTTPBadRequest(explanation=e.format_message()) def _validate_server_name(self, value): self._check_string_length(value, 'Server name', max_length=255) @@ -1365,7 +1365,7 @@ class Controller(wsgi.Controller): common.raise_http_conflict_for_instance_invalid_state(state_error, 'createImage') except exception.Invalid as err: - raise exc.HTTPBadRequest(explanation=str(err)) + raise exc.HTTPBadRequest(explanation=err.format_message()) # build location of newly-created image entity image_id = str(image['id']) |
