feat: add error handling for file writing in InputOutput class

This commit is contained in:
Paul Gauthier 2024-09-03 08:33:22 -07:00 committed by Paul Gauthier (aider)
parent b3928dabbc
commit b3ce70234e

View file

@ -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: