diff --git a/nova/api/openstack/wsgi.py b/nova/api/openstack/wsgi.py index 6ab4f63cfc3..e440889a0da 100644 --- a/nova/api/openstack/wsgi.py +++ b/nova/api/openstack/wsgi.py @@ -654,11 +654,12 @@ def __exit__(self, ex_type, ex_value, ex_traceback): return True if isinstance(ex_value, exception.NotAuthorized): - msg = unicode(ex_value) + msg = unicode(ex_value.message % ex_value.kwargs) raise Fault(webob.exc.HTTPForbidden(explanation=msg)) elif isinstance(ex_value, exception.Invalid): + msg = unicode(ex_value.message % ex_value.kwargs) raise Fault(exception.ConvertedException( - code=ex_value.code, explanation=unicode(ex_value))) + code=ex_value.code, explanation=msg)) # Under python 2.6, TypeError's exception value is actually a string, # so test # here via ex_type instead: @@ -1167,6 +1168,10 @@ def __call__(self, req): # Replace the body with fault details. code = self.wrapped_exc.status_int fault_name = self._fault_names.get(code, "computeFault") + explanation = self.wrapped_exc.explanation + LOG.debug(_("Returning %(code)s to user: %(explanation)s"), + {'code': code, 'explanation': explanation}) + fault_data = { fault_name: { 'code': code, diff --git a/nova/exception.py b/nova/exception.py index fe80ca25f87..ab275e2e599 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -387,6 +387,7 @@ class InvalidDevicePath(Invalid): class DevicePathInUse(Invalid): message = _("The supplied device path (%(path)s) is in use.") + code = 409 class DeviceIsBusy(Invalid):