Refactor logging_error into utils
update: pep8, and fixing log output. update2: more pep8, I'm looking at you vim update3: more formating update4: mailmap update5: more pep8 Change-Id: I38617e14260e65ed5cb81b3554479d3720850aae
This commit is contained in:
parent
495662dd6d
commit
da86c164cf
@ -1002,6 +1002,19 @@ def save_and_reraise_exception():
|
||||
raise type_, value, traceback
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def logging_error(message):
|
||||
"""Catches exception, write message to the log, re-raise.
|
||||
This is a common refinement of save_and_reraise that writes a specific
|
||||
message to the log.
|
||||
"""
|
||||
try:
|
||||
yield
|
||||
except Exception as error:
|
||||
with save_and_reraise_exception():
|
||||
LOG.exception(message)
|
||||
|
||||
|
||||
def make_dev_path(dev, partition=None, base='/dev'):
|
||||
"""Return a path to a particular device.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user