fix: Move FileNotFoundError handling up after file open and read

This commit is contained in:
Paul Gauthier (aider) 2024-08-22 08:22:06 -07:00
parent 35c6d5b569
commit b219e790a4

View file

@ -15,6 +15,9 @@ def process_markdown(filename):
try:
with open(filename, "r") as file:
content = file.read()
except FileNotFoundError:
print(json.dumps({"error": f"File '{filename}' not found."}, indent=4))
return
# Split the content into sections based on '####' headers
sections = re.split(r"(?=####\s)", content)