From ad3f29bdce3feb239b3b31ab0a7ff7a61c0ec9ad Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 28 Aug 2024 22:49:22 -0700 Subject: [PATCH] fix: improve error handling for lexer exceptions in AutoCompleter and RepoMap --- aider/io.py | 4 +++- aider/repomap.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/aider/io.py b/aider/io.py index 2942e047e..a4230e6ca 100644 --- a/aider/io.py +++ b/aider/io.py @@ -82,8 +82,10 @@ class AutoCompleter(Completer): continue try: lexer = guess_lexer_for_filename(fname, content) - except Exception: # On Windows, bad ref to time.clock which is deprecated + except Exception as ex: # On Windows, bad ref to time.clock which is deprecated + self.tool_error(f"Error lexing {fname}: {ex}") continue + tokens = list(lexer.get_tokens(content)) self.words.update( (token[1], f"`{token[1]}`") for token in tokens if token[0] in Token.Name diff --git a/aider/repomap.py b/aider/repomap.py index d04f2a11b..8a0d51f42 100644 --- a/aider/repomap.py +++ b/aider/repomap.py @@ -252,7 +252,8 @@ class RepoMap: try: lexer = guess_lexer_for_filename(fname, code) - except Exception: # On Windows, bad ref to time.clock which is deprecated + except Exception as ex: # On Windows, bad ref to time.clock which is deprecated? + self.io.tool_error(f"Error lexing {fname}: {ex}") return tokens = list(lexer.get_tokens(code))