Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: correctly handle error on backup failed

Ammar Ahmed202534fca905
diff --git a/apps/mobile/app/components/auth/change-password.js b/apps/mobile/app/components/auth/change-password.js
index 490370964..807d44ebf 100644
--- a/apps/mobile/app/components/auth/change-password.js
+++ b/apps/mobile/app/components/auth/change-password.js
@@ -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);
diff --git a/apps/mobile/app/components/sheets/migrate/index.tsx b/apps/mobile/app/components/sheets/migrate/index.tsx
index 42d084311..eb2bbeaf1 100644
--- a/apps/mobile/app/components/sheets/migrate/index.tsx
+++ b/apps/mobile/app/components/sheets/migrate/index.tsx
@@ -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;
diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx
index 90258f6b2..33e21ebca 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -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;