mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 18:54:59 +00:00
fix: Handle different OSError types in write_text method
This commit is contained in:
parent
c725c45726
commit
f7de2234f2
1 changed files with 4 additions and 1 deletions
|
@ -351,13 +351,16 @@ class InputOutput:
|
||||||
with open(str(filename), "w", encoding=self.encoding) as f:
|
with open(str(filename), "w", encoding=self.encoding) as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
return # Successfully wrote the file
|
return # Successfully wrote the file
|
||||||
except OSError as err:
|
except PermissionError as err:
|
||||||
if attempt < max_retries - 1:
|
if attempt < max_retries - 1:
|
||||||
time.sleep(delay)
|
time.sleep(delay)
|
||||||
delay *= 2 # Exponential backoff
|
delay *= 2 # Exponential backoff
|
||||||
else:
|
else:
|
||||||
self.tool_error(f"Unable to write file {filename} after {max_retries} attempts: {err}")
|
self.tool_error(f"Unable to write file {filename} after {max_retries} attempts: {err}")
|
||||||
raise
|
raise
|
||||||
|
except OSError as err:
|
||||||
|
self.tool_error(f"Unable to write file {filename}: {err}")
|
||||||
|
raise
|
||||||
|
|
||||||
def rule(self):
|
def rule(self):
|
||||||
if self.pretty:
|
if self.pretty:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue