From 44f015d3fe04bac6340c2bdcc4c51ce2b5b180bb Mon Sep 17 00:00:00 2001 From: arkohut <39525455+arkohut@users.noreply.github.com> Date: Fri, 16 Aug 2024 23:10:32 +0800 Subject: [PATCH] fix: handle none response exception --- memos/commands.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/memos/commands.py b/memos/commands.py index 024b932..096f8c6 100644 --- a/memos/commands.py +++ b/memos/commands.py @@ -276,9 +276,14 @@ async def loop_files(library_id, folder, folder_path, force, plugins): added_file_count += 1 tqdm.write(f"Added file to library: {file_path}") else: - tqdm.write( - f"Failed to add file: {response.status_code} - {response.text}" - ) + error_message = "Failed to add file" + if hasattr(response, "status_code"): + error_message += f": {response.status_code}" + if hasattr(response, "text"): + error_message += f" - {response.text}" + else: + error_message += " - Unknown error occurred" + tqdm.write(error_message) elif file_status == FileStatus.UPDATED: if succeeded: updated_file_count += 1