mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-14 16:44:59 +00:00
feat: add OSError handling for file reading operations
This commit is contained in:
parent
ee925eac08
commit
58120cb882
1 changed files with 6 additions and 0 deletions
|
@ -222,6 +222,9 @@ class InputOutput:
|
||||||
with open(str(filename), "rb") as image_file:
|
with open(str(filename), "rb") as image_file:
|
||||||
encoded_string = base64.b64encode(image_file.read())
|
encoded_string = base64.b64encode(image_file.read())
|
||||||
return encoded_string.decode("utf-8")
|
return encoded_string.decode("utf-8")
|
||||||
|
except OSError as err:
|
||||||
|
self.tool_error(f"{filename}: unable to read: {err}")
|
||||||
|
return
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self.tool_error(f"{filename}: file not found error")
|
self.tool_error(f"{filename}: file not found error")
|
||||||
return
|
return
|
||||||
|
@ -239,6 +242,9 @@ class InputOutput:
|
||||||
try:
|
try:
|
||||||
with open(str(filename), "r", encoding=self.encoding) as f:
|
with open(str(filename), "r", encoding=self.encoding) as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
except OSError as err:
|
||||||
|
self.tool_error(f"{filename}: unable to read: {err}")
|
||||||
|
return
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
self.tool_error(f"{filename}: file not found error")
|
self.tool_error(f"{filename}: file not found error")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue