Add option to make exception format errors fatal.
Adds a new fatal_exception_format_errors config option which defaults to False. This option is use to control how the base NovaException class handles errors which can occur when it formats error messages. The motivation for this change is to be able to enable exception format checking in our tests by setting fatal_exception_format_errors=True. Change-Id: Ie96261ed96bcede4a2b5ec5600cb93c15141a800
This commit is contained in:
parent
0e4076ebbd
commit
2e80b29786
@ -29,11 +29,21 @@ import itertools
|
|||||||
|
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
|
from nova.openstack.common import cfg
|
||||||
from nova.openstack.common import excutils
|
from nova.openstack.common import excutils
|
||||||
from nova.openstack.common import log as logging
|
from nova.openstack.common import log as logging
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
exc_log_opts = [
|
||||||
|
cfg.BoolOpt('fatal_exception_format_errors',
|
||||||
|
default=False,
|
||||||
|
help='make exception message format errors fatal'),
|
||||||
|
]
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
CONF.register_opts(exc_log_opts)
|
||||||
|
|
||||||
|
|
||||||
class ConvertedException(webob.exc.WSGIHTTPException):
|
class ConvertedException(webob.exc.WSGIHTTPException):
|
||||||
def __init__(self, code=0, title="", explanation=""):
|
def __init__(self, code=0, title="", explanation=""):
|
||||||
@ -137,6 +147,10 @@ class NovaException(Exception):
|
|||||||
LOG.exception(_('Exception in string format operation'))
|
LOG.exception(_('Exception in string format operation'))
|
||||||
for name, value in kwargs.iteritems():
|
for name, value in kwargs.iteritems():
|
||||||
LOG.error("%s: %s" % (name, value))
|
LOG.error("%s: %s" % (name, value))
|
||||||
|
|
||||||
|
if CONF.fatal_exception_format_errors:
|
||||||
|
raise e
|
||||||
|
else:
|
||||||
# at least get the core message out if something happened
|
# at least get the core message out if something happened
|
||||||
message = self.message
|
message = self.message
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user