mobile: correctly handle error on backup failed

This commit is contained in:
Ammar Ahmed
2024-08-19 10:51:14 +05:00
parent a57558d8ab
commit 202534fca9
3 changed files with 10 additions and 4 deletions

View File

@@ -68,7 +68,8 @@ export const ChangePassword = () => {
setLoading(true);
try {
const result = await BackupService.run(false, "change-password-dialog");
if (!result) throw new Error("Failed to create backup");
if (result.error)
throw new Error(`Failed to create backup: ${result.error}`);
await db.user.clearSessions();
await db.user.changePassword(oldPassword.current, password.current);

View File

@@ -95,9 +95,9 @@ export default function Migrate() {
await sleep(1);
const { error, report } = await BackupService.run(false, "local");
if (error) {
ToastManager.error(error, "Backup failed");
ToastManager.error(error as Error, "Backup failed");
if (report) {
reportError(error);
reportError(error as Error);
}
setLoading(false);
return;

View File

@@ -420,7 +420,12 @@ export const settingsGroups: SettingSection[] = [
});
try {
await BackupService.run(false, "local", "partial");
const result = await BackupService.run(
false,
"local",
"partial"
);
if (result.error) throw result.error as Error;
} catch (e) {
DatabaseLogger.error(e);
const error = e;