catch and report json errors parsing ctags output #63

This commit is contained in:
Paul Gauthier 2023-07-07 09:54:50 -07:00
parent 9c0ae45317
commit fb5af6ec8b

View file

@ -173,9 +173,15 @@ class RepoMap:
cmd = self.ctags_cmd + [filename]
output = subprocess.check_output(cmd, stderr=subprocess.PIPE).decode("utf-8")
output = output.splitlines()
output_lines = output.splitlines()
data = [json.loads(line) for line in output]
data = []
for line in output_lines:
try:
data.append(json.loads(line))
except json.decoder.JSONDecodeError as err:
self.io.tool_error(f"Error parsing ctags output: {err}")
self.io.tool_error(repr(line))
# Update the cache
self.TAGS_CACHE[cache_key] = {"mtime": file_mtime, "data": data}