refactor: handle file read errors in linter

This commit is contained in:
Paul Gauthier (aider) 2024-08-29 19:21:11 -07:00
parent d23f816353
commit 8d4d7af7d0

View file

@ -76,7 +76,11 @@ class Linter:
def lint(self, fname, cmd=None):
rel_fname = self.get_rel_fname(fname)
code = Path(fname).read_text(self.encoding)
try:
code = Path(fname).read_text(encoding=self.encoding, errors='replace')
except Exception as e:
print(f"Error reading file {fname}: {str(e)}")
return
if cmd:
cmd = cmd.strip()