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:
Aaron Lee 2011-11-08 20:23:14 -06:00 committed by Aaron Lee
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.