summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorAlex Meade <alex.meade@rackspace.com>2011-07-12 14:19:30 -0400
committerAlex Meade <alex.meade@rackspace.com>2011-07-12 14:19:30 -0400
commitc085294ccb6a8d449ccfd5739be67ee12538f48f (patch)
treea7156832b847a8ab370e19bcf16fc14496948e81 /nova/api
parent7a700362d63de1da51e9a890d854c3b0eeb97aae (diff)
Updated some common.py functions to raise ValueErrors instead of HTTPBadRequests
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/common.py13
1 files changed, 7 insertions, 6 deletions
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