Merge "Refactor MagnumException to reduce complexity"

This commit is contained in:
Jenkins 2015-10-23 01:13:53 +00:00 committed by Gerrit Code Review
commit 373d73d1f7
2 changed files with 5 additions and 10 deletions

View File

@ -193,11 +193,8 @@ class MagnumException(Exception):
def __init__(self, message=None, **kwargs):
self.kwargs = kwargs
if 'code' not in self.kwargs:
try:
self.kwargs['code'] = self.code
except AttributeError:
pass
if 'code' not in self.kwargs and hasattr(self, 'code'):
self.kwargs['code'] = self.code
if message:
self.message = message
@ -207,10 +204,8 @@ class MagnumException(Exception):
except Exception as e:
# kwargs doesn't match a variable in the message
# log the issue and the kwargs
LOG.exception(_LE('Exception in string format operation'))
for name, value in kwargs.items():
LOG.error(_LE("%(name)s: %(value)s") %
{'name': name, 'value': value})
LOG.exception(_LE('Exception in string format operation, '
'kwargs: %s') % kwargs)
try:
if CONF.fatal_exception_format_errors:
raise e

View File

@ -26,7 +26,7 @@ deps =
[testenv:pep8]
commands =
doc8 -e .rst specs/ doc/source/ contrib/ CONTRIBUTING.rst HACKING.rst README.rst
flake8 --max-complexity 11 {posargs}
flake8 --max-complexity 10 {posargs}
[testenv:venv]
commands = {posargs}