From c085294ccb6a8d449ccfd5739be67ee12538f48f Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Tue, 12 Jul 2011 14:19:30 -0400 Subject: Updated some common.py functions to raise ValueErrors instead of HTTPBadRequests --- nova/api/openstack/common.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 83854b13f..79969d393 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -133,7 +133,7 @@ def get_id_from_href(href): return int(urlparse(href).path.split('/')[-1]) except: LOG.debug(_("Error extracting id from href: %s") % href) - raise webob.exc.HTTPBadRequest(_('could not parse id from href')) + raise ValueError(_('could not parse id from href')) def remove_version_from_href(href): @@ -146,11 +146,12 @@ def remove_version_from_href(href): try: #matches /v#.# new_href = re.sub(r'[/][v][0-9]*.[0-9]*', '', href) - if new_href == href: - msg = _('href does not contain version') - raise webob.exc.HTTPBadRequest(explanation=msg) - return new_href except: LOG.debug(_("Error removing version from href: %s") % href) msg = _('could not parse version from href') - raise webob.exc.HTTPBadRequest(explanation=msg) + raise ValueError(msg) + + if new_href == href: + msg = _('href does not contain version') + raise ValueError(msg) + return new_href -- cgit