From 58120cb882066f253f9c4e33d1ecf51b42900e5f Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 31 Aug 2024 07:58:19 -0700 Subject: [PATCH] feat: add OSError handling for file reading operations --- aider/io.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/aider/io.py b/aider/io.py index 56259c6a2..d59dd7b1a 100644 --- a/aider/io.py +++ b/aider/io.py @@ -222,6 +222,9 @@ class InputOutput: with open(str(filename), "rb") as image_file: encoded_string = base64.b64encode(image_file.read()) return encoded_string.decode("utf-8") + except OSError as err: + self.tool_error(f"{filename}: unable to read: {err}") + return except FileNotFoundError: self.tool_error(f"{filename}: file not found error") return @@ -239,6 +242,9 @@ class InputOutput: try: with open(str(filename), "r", encoding=self.encoding) as f: return f.read() + except OSError as err: + self.tool_error(f"{filename}: unable to read: {err}") + return except FileNotFoundError: self.tool_error(f"{filename}: file not found error") return