diff --git a/aider/io.py b/aider/io.py index 60162fd3a..a6dfa9b2d 100644 --- a/aider/io.py +++ b/aider/io.py @@ -259,8 +259,11 @@ class InputOutput: def write_text(self, filename, content): if self.dry_run: return - with open(str(filename), "w", encoding=self.encoding) as f: - f.write(content) + try: + with open(str(filename), "w", encoding=self.encoding) as f: + f.write(content) + except OSError as err: + self.tool_error(f"Unable to write file {filename}: {err}") def rule(self): if self.pretty: