Skip to content

Commit

Permalink
Merge "Add _FATAL_EXCEPTION_FORMAT_ERRORS global."
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jan 14, 2013
2 parents 88d4a86 + 8507261 commit 08a6859
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions keystone/exception.py
Expand Up @@ -22,6 +22,9 @@
CONF = config.CONF
LOG = logging.getLogger(__name__)

# Tests use this to make exception message format errors fatal
_FATAL_EXCEPTION_FORMAT_ERRORS = False


class Error(StandardError):
"""Base error class.
Expand All @@ -37,10 +40,13 @@ def __init__(self, message=None, **kwargs):

try:
message = self._build_message(message, **kwargs)
except KeyError:
except KeyError as e:
# if you see this warning in your logs, please raise a bug report
LOG.warning('missing expected exception kwargs (programmer error)')
message = self.__doc__
if _FATAL_EXCEPTION_FORMAT_ERRORS:
raise e
else:
LOG.warning('missing exception kwargs (programmer error)')
message = self.__doc__

super(Error, self).__init__(message)

Expand Down

0 comments on commit 08a6859

Please sign in to comment.