From b3ce70234e4bfffc0b587c314270109ba51b49e1 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Tue, 3 Sep 2024 08:33:22 -0700 Subject: [PATCH] feat: add error handling for file writing in InputOutput class --- aider/io.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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: