From 05704eea39b24975c856b1b2538a1fe44b7eba0a Mon Sep 17 00:00:00 2001 From: Tim McCormack Date: Tue, 18 Jan 2022 20:24:49 +0000 Subject: [PATCH] fix: When xsslint fails with error, list which file it failed on (#29780) In my case, xsslint was failing with a UnicodeDecodeError -- having this try/except block helped me discover that it was reading files in my virtualenv. --- scripts/xsslint/xsslint/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/xsslint/xsslint/main.py b/scripts/xsslint/xsslint/main.py index 834d9e6c25..f8f8672b74 100644 --- a/scripts/xsslint/xsslint/main.py +++ b/scripts/xsslint/xsslint/main.py @@ -55,9 +55,12 @@ def _process_file(full_path, template_linters, options, summary_results, out): num_violations = 0 directory = os.path.dirname(full_path) file_name = os.path.basename(full_path) - for template_linter in template_linters: - results = template_linter.process_file(directory, file_name) - results.print_results(options, summary_results, out) + try: + for template_linter in template_linters: + results = template_linter.process_file(directory, file_name) + results.print_results(options, summary_results, out) + except BaseException as e: + raise Exception(f"Failed to process path: {full_path}") from e def _process_os_dir(directory, files, template_linters, options, summary_results, out):