mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
feat: better backup errors (#2290)
Instead of creating error reports show the error to user use BackupVersion.unknown
This commit is contained in:
parent
d342173239
commit
e03dcc7fe9
3 changed files with 18 additions and 8 deletions
|
@ -177,7 +177,7 @@ class BackupServiceV3 extends $BackupService {
|
||||||
final archive = ZipDecoder().decodeStream(inputStream);
|
final archive = ZipDecoder().decodeStream(inputStream);
|
||||||
final metadataFile = archive.findFile('metadata.json');
|
final metadataFile = archive.findFile('metadata.json');
|
||||||
if (metadataFile == null) {
|
if (metadataFile == null) {
|
||||||
throw Exception('Invalid v3 backup: missing metadata.json');
|
return BackupVersion.unknown;
|
||||||
}
|
}
|
||||||
final metadataBytes = metadataFile.rawContent!.readBytes();
|
final metadataBytes = metadataFile.rawContent!.readBytes();
|
||||||
final metadataString = utf8.decode(metadataBytes);
|
final metadataString = utf8.decode(metadataBytes);
|
||||||
|
@ -188,7 +188,7 @@ class BackupServiceV3 extends $BackupService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw Exception('Invalid backup file: unknown version');
|
return BackupVersion.unknown;
|
||||||
} finally {
|
} finally {
|
||||||
raf.closeSync();
|
raf.closeSync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,8 +173,19 @@ class RestoreFromBackupPage extends BasePage {
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
await restoreFromBackupViewModel.import(textEditingController.text);
|
await restoreFromBackupViewModel.import(textEditingController.text);
|
||||||
|
} catch (e) {
|
||||||
|
await showPopUp<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (_) {
|
||||||
|
return AlertWithOneAction(
|
||||||
|
alertTitle: S.current.error,
|
||||||
|
alertContent: e.toString(),
|
||||||
|
buttonText: S.of(context).ok,
|
||||||
|
buttonAction: () => Navigator.of(context).pop());
|
||||||
|
});
|
||||||
|
}
|
||||||
textEditingController.text = '';
|
textEditingController.text = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,11 @@ abstract class RestoreFromBackupViewModelBase with Store {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await backupService.importBackupFile(file, password);
|
await backupService.importBackupFile(file, password);
|
||||||
} catch (e, s) {
|
} catch (e) {
|
||||||
if (e.toString().contains("unknown_backup_version")) {
|
if (e.toString().contains("unknown_backup_version")) {
|
||||||
state = FailureState('This is not a valid backup file, please make sure you selected the correct backup file');
|
state = FailureState('This is not a valid backup file, please make sure you have selected the correct one');
|
||||||
} else {
|
} else {
|
||||||
state = FailureState('Failed to restore backup, please try again');
|
state = FailureState(e.toString());
|
||||||
ExceptionHandler.onError(FlutterErrorDetails(exception: e, stack: s));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue