Add a error handling on backup operation

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2025-07-24 19:05:55 -03:00
parent 890fc470bb
commit 209099cc5e
2 changed files with 9 additions and 3 deletions

View File

@ -27,7 +27,7 @@ class BackupService:
if file_path.is_file():
arcname = file_path.relative_to(diaries_root_path.parent)
zipf.write(file_path, arcname=arcname)
return True, None
return True, filename
except Exception as e:
return False, str(e)

View File

@ -306,7 +306,13 @@ class DiaryListScreen(Screen):
session = self.app.service_manager.get_session()
if session:
backup_service = BackupService(session)
result = backup_service.create_backup()
result_operation,result_data = backup_service.create_backup()
else:
self.notify("You must be logged in to perform this action")
self.notify(f"Backup result: {result}")
if result_operation:
self.notify(f"Backup result: {result_data}")
else:
self.notify(f"Error performing backup {result_data}")
raise Exception("Error performing backup")
self.app.exit()