[skip ci] exception handling

This commit is contained in:
Matthew Fosse 2024-11-04 09:02:38 -08:00
parent 0603aaa19e
commit 887021a6b1
2 changed files with 5 additions and 2 deletions

View file

@ -102,7 +102,8 @@ class MwebLogsPage extends BasePage {
Future<void> share(BuildContext context) async {
final filePath = (await getAppDir()).path + "/debug.log";
await mwebSettingsViewModelBase.saveLogsLocally(filePath);
bool success = await mwebSettingsViewModelBase.saveLogsLocally(filePath);
if (!success) return;
await ShareUtil.shareFile(filePath: filePath, fileName: "debug.log", context: context);
await mwebSettingsViewModelBase.removeLogsLocally(filePath);
}

View file

@ -47,7 +47,7 @@ abstract class MwebSettingsViewModelBase with Store {
_settingsStore.mwebAlwaysScan = value;
}
Future<void> saveLogsLocally(String filePath) async {
Future<bool> saveLogsLocally(String filePath) async {
try {
final appSupportPath = (await getApplicationSupportDirectory()).path;
final logsFile = File("$appSupportPath/logs/debug.log");
@ -55,12 +55,14 @@ abstract class MwebSettingsViewModelBase with Store {
throw Exception('Logs file does not exist');
}
await logsFile.copy(filePath);
return true;
} catch (e, s) {
ExceptionHandler.onError(FlutterErrorDetails(
exception: e,
stack: s,
library: "Export Logs",
));
return false;
}
}