TypeError API exceptions get logged incorrectly

Fixes bug 942431

LOG.exception() always logs sys.exc_info() which does not always
represent the real exception we want to log.  This changes the wsgi
ResourceExceptionHandler context manager to LOG.error() the traeback
info that's passed to __exit__()

Change-Id: I0c3728a9ee740597feb828a513aea76e7849efc6
This commit is contained in:
Chris Behrens
2012-02-28 07:34:08 +00:00
parent e9b627a1c8
commit fab893f333

View File

@@ -21,7 +21,6 @@ from xml.parsers import expat
from lxml import etree
import webob
from webob import exc
from nova import exception
from nova import log as logging
@@ -574,7 +573,9 @@ class ResourceExceptionHandler(object):
msg = unicode(ex_value)
raise Fault(webob.exc.HTTPForbidden(explanation=msg))
elif isinstance(ex_value, TypeError):
LOG.exception(ex_value)
exc_info = (ex_type, ex_value, ex_traceback)
LOG.error(_('Exception handling resource: %s') % ex_value,
exc_info=exc_info)
raise Fault(webob.exc.HTTPBadRequest())
elif isinstance(ex_value, Fault):
LOG.info(_("Fault thrown: %s"), unicode(ex_value))