From 7143aee3a52686fd3c56919a32b35d73fece13a1 Mon Sep 17 00:00:00 2001 From: didebughu Date: Fri, 10 Mar 2023 17:26:10 +0800 Subject: [PATCH] :bug: Handle xml file parsing exception --- client/tool/util/tscan.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/tool/util/tscan.py b/client/tool/util/tscan.py index eb08f2529..bda4a8de8 100644 --- a/client/tool/util/tscan.py +++ b/client/tool/util/tscan.py @@ -24,7 +24,7 @@ from util.pathlib import PathMgr from task.scmmgr import SCMMgr from util.subprocc import SubProcController - +from util.exceptions import AnalyzeTaskError class Tscan(CodeLintModel): def analyze(self, params, tc_home, bin_name, want_suffix): @@ -66,7 +66,10 @@ def analyze(self, params, tc_home, bin_name, want_suffix): def _format_issue(self, output_file): issues = [] - result_tree = ET.parse(output_file) + try: + result_tree = ET.parse(output_file) + except ET.ParseError: + raise AnalyzeTaskError("源文件编码格式错误,建议启用WrongEncoding规则检测源文件编码格式") root = result_tree.getroot() for error in root: error_attr = error.attrib