refactor: improve chat history file error handling and messaging

This commit is contained in:
Paul Gauthier 2024-10-30 06:37:59 -07:00 committed by Paul Gauthier (aider)
parent ea3359fb4b
commit 854d908fe0

View file

@ -694,11 +694,9 @@ class InputOutput:
try: try:
with self.chat_history_file.open("a", encoding=self.encoding, errors="ignore") as f: with self.chat_history_file.open("a", encoding=self.encoding, errors="ignore") as f:
f.write(text) f.write(text)
except (PermissionError, OSError): except (PermissionError, OSError) as err:
self.tool_error( print(f"Warning: Unable to write to chat history file {self.chat_history_file}.")
f"Warning: Unable to write to chat history file {self.chat_history_file}." print(err)
" Permission denied."
)
self.chat_history_file = None # Disable further attempts to write self.chat_history_file = None # Disable further attempts to write
def format_files_for_input(self, rel_fnames, rel_read_only_fnames): def format_files_for_input(self, rel_fnames, rel_read_only_fnames):