From dafa4dc129daa4eeab5fa697d35d806a3a6ec994 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Tue, 14 Aug 2018 10:16:39 +0200 Subject: [PATCH] update: ensure that exceptions during the update process are logged If an exception occurred during the update then we were managing to save the update record, but we did not include the exception traceback in the log for the update. Catch the exception and log it which ensures it gets captured in the update record and still gets printed as well. Signed-off-by: Paul Eggleton --- layerindex/update.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/layerindex/update.py b/layerindex/update.py index 1452949..aea7cd0 100755 --- a/layerindex/update.py +++ b/layerindex/update.py @@ -540,6 +540,10 @@ def main(): except KeyboardInterrupt: logger.info('Update interrupted, exiting') sys.exit(254) + except Exception: + import traceback + logger.error(traceback.format_exc().rstrip()) + sys.exit(1) finally: update.log = ''.join(listhandler.read()) update.finished = datetime.now()