diff --git a/lib/helpers/serialization/base_serialization_helper.dart b/lib/helpers/serialization/base_serialization_helper.dart index cc29648..cf4df6c 100644 --- a/lib/helpers/serialization/base_serialization_helper.dart +++ b/lib/helpers/serialization/base_serialization_helper.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:comunic/constants.dart'; import 'package:comunic/utils/flutter_utils.dart'; +import 'package:comunic/utils/log_utils.dart'; import 'package:path/path.dart' as path; import 'package:path_provider/path_provider.dart'; @@ -54,7 +55,8 @@ abstract class BaseSerializationHelper { _cache.sort(); } catch (e, s) { - print("Failed to read serialized data! $e => $s"); + logError(e, s); + print("Failed to read serialized data!"); _cache = []; } } @@ -63,9 +65,14 @@ abstract class BaseSerializationHelper { Future _saveCache() async { if (isWeb) return; - final file = await _getFilePath(); - await file.writeAsString(jsonEncode( - _cache.map((e) => e.toJson()).toList().cast>())); + try { + final file = await _getFilePath(); + await file.writeAsString(jsonEncode( + _cache.map((e) => e.toJson()).toList().cast>())); + } catch (e, s) { + print("Failed to write file!"); + logError(e, s); + } } /// Get the current list of elements