Merge "Cleaning up exception handling"

This commit is contained in:
Jenkins 2013-01-15 19:53:32 +00:00 committed by Gerrit Code Review
commit 781a9c1cf2

@ -538,10 +538,10 @@ class Controller(wsgi.Controller):
marker=marker) marker=marker)
except exception.MarkerNotFound as e: except exception.MarkerNotFound as e:
msg = _('marker [%s] not found') % marker msg = _('marker [%s] not found') % marker
raise webob.exc.HTTPBadRequest(explanation=msg) raise exc.HTTPBadRequest(explanation=msg)
except exception.FlavorNotFound as e: except exception.FlavorNotFound as e:
msg = _("Flavor could not be found") msg = _("Flavor could not be found")
raise webob.exc.HTTPUnprocessableEntity(explanation=msg) raise exc.HTTPUnprocessableEntity(explanation=msg)
if is_detail: if is_detail:
self._add_instance_faults(context, instance_list) self._add_instance_faults(context, instance_list)
@ -828,21 +828,24 @@ class Controller(wsgi.Controller):
try: try:
min_count = int(min_count) min_count = int(min_count)
except ValueError: except ValueError:
raise webob.exc.HTTPBadRequest(_('min_count must be an ' msg = _('min_count must be an integer value')
'integer value')) raise exc.HTTPBadRequest(explanation=msg)
if min_count < 1: 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: try:
max_count = int(max_count) max_count = int(max_count)
except ValueError: except ValueError:
raise webob.exc.HTTPBadRequest(_('max_count must be an ' msg = _('max_count must be an integer value')
'integer value')) raise exc.HTTPBadRequest(explanation=msg)
if max_count < 1: 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: 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 auto_disk_config = False
if self.ext_mgr.is_loaded('OS-DCF'): if self.ext_mgr.is_loaded('OS-DCF'):
@ -1202,7 +1205,8 @@ class Controller(wsgi.Controller):
try: try:
body = body['rebuild'] body = body['rebuild']
except (KeyError, TypeError): except (KeyError, TypeError):
raise exc.HTTPBadRequest(_("Invalid request body")) msg = _('Invalid request body')
raise exc.HTTPBadRequest(explanation=msg)
try: try:
image_href = body["imageRef"] image_href = body["imageRef"]