@@ -70,9 +70,13 @@ async def import_single_file(file):
70
70
async with ClientSession () as session :
71
71
async with AsyncClient (auth = notion_api_key ) as notion_client :
72
72
notion_importer = NotionImporter (session , notion_client )
73
- result = await notion_importer .process_file (file )
74
- return result
75
-
73
+ try :
74
+ result = await notion_importer .process_file (file )
75
+ logger .info (f"Finish file { file } " )
76
+ return ("succ" , result )
77
+ except Exception as e :
78
+ logger .error (f"Error processing { file } : { str (e )} " )
79
+ return ("fail" , str (e ))
76
80
77
81
def main ():
78
82
args = parse_args ()
@@ -82,12 +86,14 @@ def main():
82
86
dir_path = Path (args .dir ) if args .dir else None
83
87
max_concurrency = args .batch
84
88
if file_path and file_path .is_file ():
85
- logger .debug (f"Begin save single html file: { file_path } ." )
86
89
result = asyncio .run (import_single_file (file_path ))
87
- logger .debug (f"Finish save single html file: { file_path } .\n { result } " )
88
90
text = Text ("Single file " , style = "default" )
89
91
text .append (f"{ file_path } " , style = "cyan" )
90
- text .append ("save to notion success." , style = "default" )
92
+ if result [0 ] == "fail" :
93
+ text .append ("save to notion failed." , style = "default" )
94
+ text .append (f"\n { result [1 ]} " , style = "red" )
95
+ else :
96
+ text .append ("save to notion success." , style = "default" )
91
97
console .print (text )
92
98
elif dir_path and dir_path .is_dir ():
93
99
logger .info (f"Begin save all html files in the dir: { dir_path } ." )
0 commit comments