mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-26 09:16:21 +02:00
update: Add exception handling for write file operation.
This commit is contained in:
parent
d83d1e105c
commit
b2b227391a
1 changed files with 10 additions and 6 deletions
|
|
@ -27,9 +27,13 @@ class File:
|
|||
Returns:
|
||||
The full filename of file, such as "/data/test.txt".
|
||||
"""
|
||||
root_path.mkdir(parents=True, exist_ok=True)
|
||||
full_path = root_path / filename
|
||||
async with aiofiles.open(full_path, mode="wb") as writer:
|
||||
await writer.write(content)
|
||||
logger.info(f"Successfully write docx: {full_path}")
|
||||
return full_path
|
||||
try:
|
||||
root_path.mkdir(parents=True, exist_ok=True)
|
||||
full_path = root_path / filename
|
||||
async with aiofiles.open(full_path, mode="wb") as writer:
|
||||
await writer.write(content)
|
||||
logger.info(f"Successfully write docx: {full_path}")
|
||||
return full_path
|
||||
except Exception as e:
|
||||
logger.error(f"Error writing file: {e}")
|
||||
raise e
|
||||
Loading…
Add table
Add a link
Reference in a new issue