better error handling of post-action hook in app

This commit is contained in:
Doug Hellmann 2012-04-22 16:13:39 -07:00
parent 6fdfe6dbf1
commit 267c759359
1 changed files with 8 additions and 2 deletions

View File

@ -150,7 +150,13 @@ class App(object):
if self.options.debug:
LOG.exception(err)
raise
LOG.error(err)
LOG.error('ERROR: %s', err)
finally:
self.clean_up(cmd, result, err)
try:
self.clean_up(cmd, result, err)
except Exception as err2:
if self.options.debug:
LOG.exception(err2)
else:
LOG.error('Could not clean up: %s', err2)
return result