Skip to content

Commit

Permalink
Don't include traceback when wrapping exceptions
Browse files Browse the repository at this point in the history
The fix in fa52cb0 strips tracebacks
from exceptions when returning them to the user, but it still spams
the log with a long traceback. We shouldn't be including the traceback
when we wrap the exception in the first place. Instead we just
include the message.

It also updates the error code to 409 for device in use since this
is actually a conflict.

Fix for:

  bug 1155315
  bug 1103324
  bug 1092610

Change-Id: I95019a3022eb52e0335c455009c13fe229475d03
(cherry picked from commit d63bd8d)
  • Loading branch information
vishvananda committed Mar 14, 2013
1 parent 9561484 commit 524a5a3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nova/api/openstack/wsgi.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions nova/exception.py
Expand Up @@ -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):
Expand Down

0 comments on commit 524a5a3

Please sign in to comment.