summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2012-12-18 09:50:56 -0500
committerDan Prince <dprince@redhat.com>2012-12-18 14:25:07 -0500
commit2e80b297865e9c7b4251f97a95adaa6f4d0d4643 (patch)
tree3c657514cd7f63beaa6cf07bcd37ec4c6157eaf5
parent0e4076ebbd0d25e5164c180e8983a36a6bdd9cb5 (diff)
downloadnova-2e80b297865e9c7b4251f97a95adaa6f4d0d4643.tar.gz
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
-rw-r--r--nova/exception.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/nova/exception.py b/nova/exception.py
index 10349f3869..b4d39bce03 100644
--- a/nova/exception.py
+++ b/nova/exception.py
@@ -29,11 +29,21 @@ import itertools
import webob.exc
+from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import log as logging
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):
def __init__(self, code=0, title="", explanation=""):
@@ -137,8 +147,12 @@ class NovaException(Exception):
LOG.exception(_('Exception in string format operation'))
for name, value in kwargs.iteritems():
LOG.error("%s: %s" % (name, value))
- # at least get the core message out if something happened
- message = self.message
+
+ if CONF.fatal_exception_format_errors:
+ raise e
+ else:
+ # at least get the core message out if something happened
+ message = self.message
super(NovaException, self).__init__(message)