From 46901fb8cadc6ea94922f8ae36fed012b58b595a Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 6 Nov 2018 10:26:21 -0800 Subject: [PATCH] releasetools: Log the exceptions before rethrowing. In Append2Simg and Append in verity_utils.py, we catch and rethrow exceptions as BuildVerityImageError. However, this suppresses the traceback from the original exception which usually indicates the actual cause. We can better handle this with the raise statement in Python 3, which is however unavailable in Python 2. This CL logs the exception before rethrowing to retain the useful bits. Test: Inject an error to append2simg. `m -j systemimage` with aosp_marlin-userdebug. Check the output. Change-Id: I0c2f57d6023fa1038256b85fa98d57ad0244a70d --- tools/releasetools/verity_utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/releasetools/verity_utils.py b/tools/releasetools/verity_utils.py index 00af29685b..da6141227c 100644 --- a/tools/releasetools/verity_utils.py +++ b/tools/releasetools/verity_utils.py @@ -168,6 +168,7 @@ def Append2Simg(sparse_image_path, unsparse_image_path, error_message): try: common.RunAndCheckOutput(cmd) except: + logger.exception(error_message) raise BuildVerityImageError(error_message) @@ -182,6 +183,7 @@ def Append(target, file_to_append, error_message): for line in input_file: out_file.write(line) except IOError: + logger.exception(error_message) raise BuildVerityImageError(error_message)