Skip to content

Commit

Permalink
🐛 Handle xml file parsing exception
Browse files Browse the repository at this point in the history
  • Loading branch information
didebughu committed Mar 10, 2023
1 parent 29944b1 commit 7143aee
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/tool/util/tscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7143aee

Please sign in to comment.